首页 > 编程语言 > 详细

gcc 编译c++文件

时间:2019-09-10 18:46:58      阅读:153      评论:0      收藏:0      [点我收藏+]

 

#include <stdio.h>
//将类定义在命名空间中
namespace Diy{
    class Student{
    public:
        char *name;
        int age;
        float score;
  
    public:
        void say(){
            printf("%s的年龄是 %d,成绩是 %f\n", name, age, score);
        }
    };
}
int main(){
    Diy::Student stu1;
    stu1.name = "小明";
    stu1.age = 15;
    stu1.score = 92.5f;
    stu1.say();
    return 0;
}

编译

 gcc -lstdg++ test.cpp

运行

./a.out

 

gcc 编译c++文件

原文:https://www.cnblogs.com/sea-stream/p/11499094.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!