Issue with Type Casting in C++

I’m currently facing an issue while trying to convert a variable from type double to int in C++. When using the static_cast or int() operator for the conversion, the result doesn’t seem to be correct. Can someone guide me on how to properly perform this conversion? #include <iostream> int main() { double myDouble = 3.14;… Read More Issue with Type Casting in C++

Is type conversion having a covariance error?

I’m learning how to build a compiler through a YouTube video, and there’s a part where there’s a type conversion error, in the locals.Add(parameter, value); section there’s this error from Visual Studio for Mac, saying that the variable parameter with the type ParameterSymbol can’t be converted to VariableSymbol. Argument 1: cannot convert from ‘Compiler.SupportedExpressions.Symbols.ParameterSymbol’ to… Read More Is type conversion having a covariance error?

C# type casting isn't checked when a function takes a dynamic object as input parameter

I have a function that takes in a dynamic type object. The function does work to parse that object then returns back some information about what it parsed. For some weird reason when I take the returned object and store it into another variable, that new variable doesn’t check to see that the object type… Read More C# type casting isn't checked when a function takes a dynamic object as input parameter

SQL Convert Varchar to Date

I have a query that grabs a yyyy-MM-dd format from a large storage field by substringing, so the value is automatically a varchar. An example of the entire record’s contents is below: EmployeeName$Test User Email$test@test.com ADUsername$tuser TermDate$2023-07-13 EmployeeNumber$12345 Department$Tech The following SQL query works and returns all data correctly, where TermDateString is never null and… Read More SQL Convert Varchar to Date

elegant Java class downcast

Let A be a superclass of AB and AC. Given a method: public void handleStuff(A someObject) { if(someObject instanceof AB){ ((AB)someObject).someABFunction(); } else if(someObject instanceof AC) { ((AC)someObject).someACFunction(); } } I don’t like the double checking/casting operation here; is there any other way to code this without first checking for a type and then casting?… Read More elegant Java class downcast