
本文共 3083 字,大约阅读时间需要 10 分钟。
C++������������������������������������������
���C++������������������������������������������������������������������������������������������������������������������������������������
1. ���������������������������������
���������������C++������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ A
���������������������������������������������������������������
class A { public: int a; int b;}
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
2. ������������������������������������������
������������������������������������.cpp
������������������������class A
������������������������������������������������������������������������������������������������������������obj
������������������������������
���������
#includeusing namespace std;class A { public: int a; int b;}class A { public: int a;}int main() { A obj; obj.a; // ��������������������������������������� A return 0;}
���������������������������������������������������������������������������
3. ������������������������������������������
C++������������������������������������������������.cpp
���������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������
// main.cpp#include "test.h"#includeusing namespace std;int main() { B b; b.fun(2); return 0;}
// test.h#ifndef _TEST_H#define _TEST_H#includeusing namespace std;template class B {public: void fun(T obj) { cout << "void fun(T obj)" << endl; cout << obj << endl; }#endif
������������������������������������������������������main.cpp
���test.h
������������������B
���������������
4. ���������������������������������������������������������
���C++������������������������������������������������������������������������������������������������������������������������������������������������������������.cpp
���.cpp
������������������������B
���������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������int a;
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������������������
- ���������������������������������������������������������������������������������������������������������������������������������������
- ������������������������������������������������������������������������������������������������������������������������������������
������������������������������������������������������������C++���������������������
发表评论
最新留言
关于作者
