By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,994 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,994 IT Pros & Developers. It's quick & easy.

CArray

P: n/a
Ok here is sample of code:

CArray <MyClass,MyClassarr;
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?

Aug 12 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Dymus wrote:
Ok here is sample of code:

CArray <MyClass,MyClassarr;
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 12 '07 #2

P: n/a
On Aug 12, 9:44 pm, Dymus <dima.petchon...@gmail.comwrote:
Ok here is sample of code:
CArray <MyClass,MyClassarr;
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?

--
James Kanze (GABI Software) email:james.ka...@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Aug 13 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.