发布网友
共4个回答
热心网友
就一点不同:C结构中不能有行为(函数),但C++结构中可有行为(函数)。如下面代码:(在VC++6.0中测试通过)
---------------
#include <stdio.h>
#include <iostream.h>
struct sr
{
int a;
void fn();
};
void sr::fn()
{
cout<<"fn1"<<endl;
}
void main()
{
sr s;
s.a=0;
s.fn();
cout<<s.a<<endl;
}
------回答完毕。
热心网友
c是面向过程的语言,c++是面向对象的语言
热心网友
C++的结构除了具备C结构的全部性质外,还带有类的特点,可实现象类一样的功能
热心网友
同:一块块的。看起来方便,用起来易冗余。
不同:c以函数为块
c++以类为块,就是把函数放进结构体了