1 Star 0 Fork 0

CoderQi/cpp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
类模板基本语法.cpp 785 Bytes
一键复制 编辑 原始数据 按行查看 历史
CoderQi 提交于 2023-04-22 22:15 +08:00 . 类模板
//#include<iostream>
//#include<string>
//using namespace std;
//template<class NameType,class AgeType>
//class Person
//{
//public:
// //Person的构造函数
// Person(NameType name,AgeType age)
// {
// this->m_Name = name;//this指针指向被调函数所属对象
// this->m_Age = age;
//
// }
// void showPerson()
// {
// cout << this->m_Name << "的年龄是" << this->m_Age << endl;
// }
// NameType m_Name;
// AgeType m_Age;
//};
//void test01()
//{
// //构造函数的三种调用方法
// //1.括号法
// /*Person<string, int>p1("孙悟空", 999);*/
// //2.显示法
// Person<string,int>p2=Person<string, int>("孙悟空", 999);
// p2.showPerson();
// //3.隐式转换法
// /*cout << p2.m_Name << "的年龄是" << p2.m_Age << endl;*/
//}
//int main()
//{
// test01();
// return 0;
//}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/programmercg/cpp.git
git@gitee.com:programmercg/cpp.git
programmercg
cpp
cpp
master

搜索帮助