0

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 ...

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

1

1 Answer 1

0

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++.

Sign up to request clarification or add additional context in comments.

2 Comments

Oh my god .... Thanks for your help, So that was wrong to declare a struct ,right ?
You're using struct correctly for C++ but incorrectly for C. The two colons in BookData are incorrect in both languages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.