0

everyone

I try to add c++ class into my iphone project.but I got so many error message

for example , in MyClass.h

struct DefaultData{
    char id[32];
    char name[256];
};


struct DefaultDataList{
    int size;
    //Here got a error1 : **Expected specifier-qualifier-list before "DefaultData"**
    DefaultData *dataList;
};

//Here got error 2:**Expected identifier or'(' before ':' token**
struct BookData:DefaultData{
    char class_id[32];
    char country_id[32];
    char author[128];
    char file_type[32];
    char file_size[32];
    :
    :
};

Does anyone know what's going on here ???

beacuse the c++ is not create by me ...

And I don't write c++ before , so I'm very confused ...

Does it have any tutorial is about How to import C++ class to object-c ???

Thanks for any reply or answers

Webber

Webber Lai
  • 2,014
  • 5
  • 35
  • 66
  • 2
    http://stackoverflow.com/questions/2683101/use-c-with-objective-c-in-xcode/2683131#2683131 – peko Oct 05 '11 at 11:29

1 Answers1

1

Objective-C does not support C++ classes - you need Objective-C++ to mix C++ with Objective-C.

As for your errors, the code you've posted is neither valid C nor C++.

JoeG
  • 12,994
  • 1
  • 38
  • 63
  • Oh my god .... Thanks for your help, So that was wrong to declare a struct ,right ? – Webber Lai Oct 05 '11 at 15:43
  • 1
    You're using struct correctly for C++ but incorrectly for C. The two colons in BookData are incorrect in both languages. – JoeG Oct 06 '11 at 11:16