C++入门

mac2026-08-21  1

环境搭建: visual studio code 软件下载安装 下载对应的C++,runner code等插件

基础代码 #include using namespace std; class Box{ public: int getArea(); double length; double width; double height; int a; double b; float c; void print(int data){ cout<<“int”<<data<<endl; } void print(double data){ cout<<“doubel”<<data<<endl; } void print(float data){ cout<<“fudian” <<data<<endl; }

void setlength(double len){ length=len; } void setwidth(double wid){ width=wid; } void setheight(double heig){ height=heig; }

}; class React:public Box{ public: int getarae(){ return widthheightlength; } }; class Triangle:public Box{ public: int getArea(){ return widthheight; } }; int main(){ cout << “Content-type:text/html\r\n\r\n”; cout << “\n”; cout << “\n”; cout << “Hello World - 第一个 CGI 程序\n”; cout << “\n”; cout << “\n”; cout << “

Hello World! 这是我的第一个 CGI 程序

\n”; cout << “\n”; cout << “\n”; React react; react.setheight(20); react.setlength(22); react.setwidth(34); cout<<react.getarae()<<endl; Box box1; box1.print(1); box1.print(2.0f); box1.print(3.0); box1.length=20; box1.width=30; box1.height=40; double volume; volume=box1.heightbox1.width*box1.length; cout<<volume<<endl; }

最新回复(0)