reference

Using references to access class objects C++

两盒软妹~` 提交于 2019-12-31 05:45:09
问题 This one has me stumped. What I'm trying to do is get a reference variable in a wrapper class to point to a struct object in the class it wraps so that any setting of variables in the struct from other classes that use the wrapper class, actually are set in the wrapped class not the wrappper class. To do this I tried to simply create a reference in the wrap class to the struct in the wrapped class like class CClassWrap { CClass::plot_type& PlotArgs; } and then init PlotArgs CClassWrap:

Passing by reference character arrays

こ雲淡風輕ζ 提交于 2019-12-31 05:26:09
问题 I'm attempting to pass a character array located in _name into a char reference called name. However, when passing the array pointer into the reference, it would ONLY display the first character rather than the whole string. My question is how would you create a Character reference array to copy the original pointer into it then displaying it? As show in item.cpp we copy _name pointer into reference of name then return name, it however only displays the first character of the string. I will

Passing variables by reference and construct new objects

♀尐吖头ヾ 提交于 2019-12-31 05:08:06
问题 Hello there i have code like this one below and i don't know why it doesn't work. class Clazz2; class Clazz { public: void smth(Clazz2& c) { } void smth2(const Clazz2& c) { } }; class Clazz2 { int a,b; }; int main() { Clazz a; Clazz2 z; a.smth(z); //a.smth(Clazz2()); //<-- this doesn't work a.smth2(Clazz2()); // <-- this is ok return 0; } I have compilation error: g++ -Wall -c "test.cpp" (in directory: /home/asdf/Desktop/tmp) test.cpp: In function ‘int main()’: test.cpp:26:17: error: no

Reference .netstandard 2.0 project in core 2.0 Runtime loading error when GenerateAssemblyInfo = false

喜欢而已 提交于 2019-12-31 05:08:05
问题 When we add the reference, we are able to use the .netstandard libs classes in our .net core console project (in Visual Studio), and it compiles. When we run the app, it immediately crashes with this error in the output window: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Could not load file or assembly 'MyNetStandard20Assembly, Version=0.1.0.0, Culture=en-us, PublicKeyToken=null'. The system cannot find the file specified. Update / Cause (still

Reference .netstandard 2.0 project in core 2.0 Runtime loading error when GenerateAssemblyInfo = false

和自甴很熟 提交于 2019-12-31 05:07:17
问题 When we add the reference, we are able to use the .netstandard libs classes in our .net core console project (in Visual Studio), and it compiles. When we run the app, it immediately crashes with this error in the output window: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Could not load file or assembly 'MyNetStandard20Assembly, Version=0.1.0.0, Culture=en-us, PublicKeyToken=null'. The system cannot find the file specified. Update / Cause (still

How to get a list of mutable strings?

无人久伴 提交于 2019-12-31 03:49:28
问题 I have the following piece of code List<String> l = new List<String>(); String s = "hello"; l.Add(s); s = "world"; When I set up some breakpoints and go through the program, after executing the last line, the value in the list is still hello instead of world . Shouldn't it equal world ? Isn't a string an object, and am I not just inserting a pointer into the list? Later on if I change the string to point to a different value ("world"), why is my list still referencing the old value? How can I

ASP.NET Website's BIN directory and references

不打扰是莪最后的温柔 提交于 2019-12-31 02:23:20
问题 Imagine the following solution: Website ABC.com (not Web Application) BLL (business logic layer in a seperate assembly) DTO (dto objects in their own assembly) DAL (data access layer in it's own assembly as well). The BLL has a reference to the DAL. The BLL has a reference to the DTO layer. The Website project references the BLL. When one compiles the website project, the following DLLs will appear in the BIN directory: BLL.dll DTO.dll DAL.dll When one goes to preview the site, an error

How to return a reference in C++

左心房为你撑大大i 提交于 2019-12-30 13:55:07
问题 If for example I create a new object in a function and I want to return its reference how can I do it? Lets say I got an IntClass that has a 'int num' field in the private. So i want to create a new element of IntClass in the function and return the reference of that object. I've tried something like that but it seems illegal (from some reason when I do such thing the Binaries gets deleted when I compile the code although I get no errors from the compiler itself (ECLIPSE): IntClass* a = new

When can I use “==” operator?

99封情书 提交于 2019-12-30 13:39:02
问题 I have found quote from jls: The equality operators may be used to compare two operands that are convertible (§5.1.8) to numeric type, or two operands of type boolean or Boolean, or two operands that are each of either reference type or the null type . All other cases result in a compile-time error. But this code String str= ""; Number num = 1; System.out.println(str == num); every operand is reference! said that it is incompatible types. Where did in jls say that these types should be

When can I use “==” operator?

天涯浪子 提交于 2019-12-30 13:36:12
问题 I have found quote from jls: The equality operators may be used to compare two operands that are convertible (§5.1.8) to numeric type, or two operands of type boolean or Boolean, or two operands that are each of either reference type or the null type . All other cases result in a compile-time error. But this code String str= ""; Number num = 1; System.out.println(str == num); every operand is reference! said that it is incompatible types. Where did in jls say that these types should be