Ask for help: C++ struct
-
Hello, everyone, Who know the different between C Struct and C++ Struct? Please tell me?
-
Hello, everyone, Who know the different between C Struct and C++ Struct? Please tell me?
In C a structure is a colection of data items only. In C++ a structure is the same as a class, accept that the default access is public instead of private. INTP Every thing is relative...
-
Hello, everyone, Who know the different between C Struct and C++ Struct? Please tell me?
guy .From your name I know you come from cn 两种结构体式一样的把 ---------------------------- Jerry yu Chinese programming fans
-
In C a structure is a colection of data items only. In C++ a structure is the same as a class, accept that the default access is public instead of private. INTP Every thing is relative...
DEAR SIR can you give a example I donot understand your say ---------------------------- Jerry yu Chinese programming fans 我的QQ 290785513 中国人的加我
-
Hello, everyone, Who know the different between C Struct and C++ Struct? Please tell me?
in addition to what John said, a C++ structure can accept the following by opposition to C structs : - visibility operators (public, protected, private) - member functions - inherit from another type a C structure is so only an aggregation of several types, all public. a C++ struct do is a class, but which members are public by default... if you don't understand more, search for a C++ book and learn about the language.
TOXCCT >>> GEII power
[toxcct][VisualCalc] -
DEAR SIR can you give a example I donot understand your say ---------------------------- Jerry yu Chinese programming fans 我的QQ 290785513 中国人的加我
in C++ :
//C++ struct definition...
struct MyStruct {
int i;
double d;
};will actually be seen by the compiler as the following code :
class MyStruct {
public:
int i;
double d;public:
MyStruct() { }
virtual ~MyStruct() { }
};see if you can find any differences...
in the same way, the following code wont compile with a pure C compiler :
struct Formula1 : public SportCar { //inheritence not allowed
private: //visibility change not allowed
Motor m;
double max_speed;public:
double getMaxSpeed(); //member functions not allowed
};
TOXCCT >>> GEII power
[toxcct][VisualCalc] -- modified at 7:05 Saturday 19th November, 2005 -
Hello, everyone, Who know the different between C Struct and C++ Struct? Please tell me?
Hello, A struct in C++ is the same as C. It's only there for compatibility with C. There is no real difference. When you use C++, you can add member functions and all the other stuff that you can use with a class. I can only advice not too do it. The main reason for this is that everybody uses a struct as a POD (Plain Old Datatype) and a class for dynamic objects. Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
-
Hello, A struct in C++ is the same as C. It's only there for compatibility with C. There is no real difference. When you use C++, you can add member functions and all the other stuff that you can use with a class. I can only advice not too do it. The main reason for this is that everybody uses a struct as a POD (Plain Old Datatype) and a class for dynamic objects. Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
Thank you very much. I find the real reason from your answer. Yesterday, I read a block source code of C++. In it, I found some structs are defined as C style, I feel very strange, So I ask this question. Now I understood it only want to treat the struct as a Datatype.
-
Thank you very much. I find the real reason from your answer. Yesterday, I read a block source code of C++. In it, I found some structs are defined as C style, I feel very strange, So I ask this question. Now I understood it only want to treat the struct as a Datatype.