reference

g++ gives error : invalid initialization of reference of type ‘char&’ from expression of type ‘unsigned char’

假如想象 提交于 2019-12-23 12:50:02
问题 when I try to compile the following code int main() { unsigned char uc; char & rc = uc; } g++ gives the following error : invalid initialization of reference of type ‘char&’ from expression of type ‘unsigned char’. The same happens when using signed char instead of unsigned char. But the following compiles well int main() { unsigned char uc; const char & rc = uc; } Why isn't it possible to initialize 'char &' with a variable of type 'unsigned char' while it is possible to initialize 'const

In a declaration with initialization, can I use a reference to uninitialized data?

痞子三分冷 提交于 2019-12-23 12:49:11
问题 I have a function that creates and returns an object. It also has a side-effect, writing a success flag into a boolean variable: struct MyObject { ... int field1; char field2; bool field3; }; MyObject CreateMyObject(bool& success) { ... } By pure coincidence it happens that I have to store the success flag in my object. So I can write it in this obvious way: bool success; MyObject x = CreateMyObject(success); x.field3 = success; Or in this way: MyObject x = CreateMyObject(x.field3); Does the

Android: How do I reference a stylable that resides in a library that my app references?

痞子三分冷 提交于 2019-12-23 12:47:47
问题 I have a custom view I created that resides in a library I'm referencing in my app. In the library I declared a styleable, which the view uses. In my app, I'm using the custom view from the library as such: <nefarious.library.myappname.views.DragDropList xmlns:ddl="http://schemas.android.com/apk/res/nefarious.library.myappname" android:id="@id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:choiceMode="singleChoice" android:clickable="true" android

How to create a cyclic reference with Arc and Weak?

做~自己de王妃 提交于 2019-12-23 12:45:11
问题 I have two structs: struct A { map: HashMap<u32, Vec<B>>, } struct B { weak: Weak<A> } When A is constructed, it will own several B , each of which links back to the A which was just constructed, similar to this: let a = Arc::new(A { map: HashMap::new() }); let b1 = B { weak: Arc::downgrade(&a) }; let b3 = B { weak: Arc::downgrade(&a) }; let b2 = B { weak: Arc::downgrade(&a) }; a.map.insert(5, vec![b1, b2]); a.map.insert(10, vec![b3]); Playground This doesn't work since Arc does not provide a

Reference Component Microsoft.CSharp could not be found

孤人 提交于 2019-12-23 11:55:12
问题 I found this problem on my C# project which I started at Visual Studio 2010, when I go to another PC I use 2008, I open the project.csprog: A get or set accessor expected and warning: The referenced component 'Microsoft.CSharp' could not be found. I think is about .NET Framework or Microsoft.CSharp is not located, because it says that: Could not resolve this reference. Could not locate the assembly "Microsoft.CSharp". Check to make sure the assembly exists on disk. If this reference is

Adding a clone of an object to a list in c# (prevent modification from outside)

∥☆過路亽.° 提交于 2019-12-23 11:53:41
问题 I have an object like 'obj1' which I want to add to a list. I can add it by just list1.add(obj1) .Now once I update obj1 , the object in my list is also updating! (I understand that I am dealing with references here) My requirement demands modifying the obj1 and add it to the list again! Instead of having two different objects, I have only one, because for both of them, the reference is the same - obj1 . Is there any way I can modify this obj1 and add it to the list and still not lose the old

Copy a list of list by value and not reference [duplicate]

谁说胖子不能爱 提交于 2019-12-23 11:52:05
问题 This question already has answers here : How to clone or copy a list? (16 answers) Copying nested lists in Python (3 answers) Closed last year . To understand why I was getting an error in a program , in which I tried to find the "minor" of a determinant, I wrote a simpler program because my variables were messed up. This function below takes in a 2 * 2 matrix as an input, and returns a list containing its rows (pointless and inefficient, I know, but I'm trying to understand the theory behind

Reading the list of References from All csproj project of solution sln (programmatically)

╄→гoц情女王★ 提交于 2019-12-23 10:55:06
问题 I have solution sln, that has many csproj projects. anyone know a way to programmatically read the list of References of all csproj projects in a VS2008 of sln file? 回答1: csproj files are just XML files. You can use XDocument from the .NET framework for this. I've done it for VS2010, but in VS2008 the tags are almost the same. Example for VS2010, you have to verify the tags and namespace: XElement projectNode = XElement.Load(fileName); XNamespace ns = "http://schemas.microsoft.com/developer

Error: Could not load file or assembly 'Oracle.ManagedDataAccessDTC' or one of its dependencies

江枫思渺然 提交于 2019-12-23 10:54:43
问题 Background I have a solution containing a Console project and an MVC4 Webapp. Both Reference Oracle.ManagedDataAccess (the managed ODP.NET data access provider). The reference is to the same file. Neither reference Oracle.ManagedDataAccess DTC. In VS Configuration Manager, the platform is listed as "Any CPU" for all configuration options. The platform target for both is "Any CPU" Problem The console application executes perfectly fine. When I try to use the MVC4 application, I see: Could not

How to use indirect reference to select a single cell or range in vba

怎甘沉沦 提交于 2019-12-23 10:04:28
问题 I need simply a code for selecting a cell, however that cell to select changes. I have a cell in the workbook that will identify what cell it should be. Cell A1 contains the cell # that should be selected. In this example cell A1 contains the word "P25", so I want the below code to reference A1 for the indirect cell ref to P25, thus select cell P25. I tried both of these lines separately: Sub IndirectCellSelect() Sheet.Range(INDIRECT(A1)).Select Range(INDIRECT(A1)).Select End Sub I get the