重新发贴:ubuntu下编译用g++编译文件的报错:未声明成员函数???
抱歉,刚才误点回车,重新发贴吧。
最近学习用ubuntu 和vim ,各种插件差不多弄清楚了,等熟悉一下发博客总结经验。下面进入正题:
用vim 写好了测试编译的文件:如下,
main.cpp
#include <iostream>#include "cat.h"using namespace std;void function ( int a, int b ){ cout<<"Hello world"<<endl;}int main (){ Cat myCat; function(3,8); char str[10]; cin >> str; cout << str <<endl; myCat.show(); myCat.cppshow(); cout << "Hello world" << endl; return 0;}#ifndef CAT_H#define CAT_Hclass Cat{private: char name[10] ;public: void show(); void cppshow(); void cinName ( char *str);};#endif /*CAT_H*/#include "cat.h"#include <iostream>using namespace std;void Cat::show(){ cout << "I am the function show" <<endl;}void Cat::cppshow(){ cout << "I am in the function cppshow" << endl;}void Cat::cinName ( char *str ){ cin >> name;}