C的struct 和 C++的struct有什么区别

C语言的struct不能有函数成员,而C++的struct可以有;
C语言的struct中数据成员没有private、public和protected访问权限的设定,而C++的struct的成员有访问权限设定;
C语言中的struct是没有继承关系的,而C++的struct却有丰富的继承关系



From:小肥羊的慢慢科研路
 

//C语言中:
struct Student{
int a;
int b;  
};


int main(){
struct Student st;//必须含有struct 
}
//C++语言中:
struct Student{
int a;
int b;  
};


int main(){
Student st;//不必含有struct 
}

struct在C和C++中的区别

猜你喜欢

转载自blog.csdn.net/tony2278/article/details/84197597