Skip to content

Commit

Permalink
增加test13_17.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
eagle51 committed Jun 11, 2016
1 parent 6e5ec08 commit 5d01acf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
35 changes: 35 additions & 0 deletions unit13/test13_17.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
using namespace std;
class numbered {
public:
numbered(numbered &){
mysn = seq++;
}
numbered() {
mysn = seq++;
}
int mysn;
private:
static int seq; //声明静态成员
};
int numbered::seq = 0; //定义并初始化静态成员(静态成员一般必须在类内声明,类外定义和初始化)
void f(numbered s)
{
cout << s.mysn << endl;
}

void f1(const numbered &s)
{
cout << s.mysn << endl;
}

int main()
{
numbered a, b = a, c = b;
f(a);f(b);f(c);
f1(a);f1(b);f1(c);
system("pause");
return 0;
}
//2016年6月11日16:18:58
//实验室
5 changes: 1 addition & 4 deletions unit13/unit13.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="test13_13.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="myHasPtr.h" />
<ClCompile Include="test13_17.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
7 changes: 1 addition & 6 deletions unit13/unit13.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="myHasPtr.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="test13_13.cpp">
<ClCompile Include="test13_17.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
Expand Down

0 comments on commit 5d01acf

Please sign in to comment.