CArray

D

Dymus

Ok here is sample of code:

CArray <MyClass,MyClass> arr;
MyClass * obj;
obj = new MyClass();
obj->some_field=some_value;
arr.Add((*obj));
delete obj;
 
V

Victor Bazarov

Dymus said:
Ok here is sample of code:

CArray <MyClass,MyClass> arr;
MyClass * obj;
obj = new MyClass();

Why not merge the two statements?
obj->some_field=some_value;
arr.Add((*obj));

Why extraneous parentheses?
delete obj;

----
Error 2664 Add cannot convert parameter 1 from class MyClass to class
MyClass.

Where is error?? or what I've missed?

Several things, the most important of which is that this newsgroup
is about C++ langauge, not about MFC. See 'microsoft.public.vc.mfc'
for help on CArray (if it's not MFC, try the newsgroup where it is
relevant), and if it's your own template, provide its definition.

Also, next time you decide to post to a newsgroup for the first time,
use a different approach: first *read* the newsgroup, then find out
where its FAQ is (if any), and read that, and only then, if your
questions haven't been answered, and you figured how to post, do.

V
 
J

James Kanze

Ok here is sample of code:
CArray <MyClass,MyClass> arr;
MyClass * obj;
obj = new MyClass();
obj->some_field=some_value;
arr.Add((*obj));
delete obj;
Error 2664 Add cannot convert parameter 1 from class MyClass to class
MyClass.
Where is error?? or what I've missed?

Hard to say without seeing the sources of CArray. What type
does CArray<>::Add take as an argument, for example?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top