CArray

Discussion in 'C++' started by Dymus, Aug 12, 2007.

  1. Dymus

    Dymus Guest

    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?
    Dymus, Aug 12, 2007
    #1
    1. Advertising

  2. Dymus wrote:
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Aug 12, 2007
    #2
    1. Advertising

  3. Dymus

    James Kanze Guest

    On Aug 12, 9:44 pm, Dymus <> wrote:
    > 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?

    --
    James Kanze (GABI Software) email:
    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
    James Kanze, Aug 13, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ishira

    CARRAY problem with ADD

    Ishira, Aug 6, 2003, in forum: C++
    Replies:
    0
    Views:
    517
    Ishira
    Aug 6, 2003
  2. Ishira

    CARRAY COpy constructor

    Ishira, Aug 7, 2003, in forum: C++
    Replies:
    2
    Views:
    561
    John Harrison
    Aug 7, 2003
  3. Mike Stenzler
    Replies:
    66
    Views:
    2,116
    Default User
    Oct 7, 2003
  4. Jethro
    Replies:
    1
    Views:
    299
    Petec
    May 30, 2004
  5. Replies:
    10
    Views:
    620
Loading...

Share This Page