C++构造函数是否可以重载为普通函数?
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream>
2
3 class ConstructorTest
4 {
5 public:
6 ConstructorTest(int i):mI(i) {std::cout << "ConstructorTest Constructor." << std::endl;}
7 int ConstructorTest() {std::cout << "ConstructorTest Function." << std::endl; return 0;}
8 private:
9 int mI;
10 };
上面的代码编译出错!
结论:C++构造函数不能重载为普通函数