-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
26 lines (25 loc) · 819 Bytes
/
main.cpp
File metadata and controls
26 lines (25 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include "mygreatclass.h"
using namespace std;
using namespace myNameSpace;
/*4 uses of static:
static function variable - static storage duration
static file scope variable - static duration, internal linkage
static class variable - static storage duration, global linkage, namespaced to class
static class method - essentially a free function namespaced to class, cannot access non-static class variables
*/
int main(int argc, char *argv[])
{
myGreatClass obj;
auto var =
myGreatClass::staticMethod();
auto var2 = myGreatClass::myVar;
auto staticFucVar =
obj.aMethod();
staticFucVar =
obj.aMethod();
std::cout<<"var "<<var <<
" var2 "<< var2 <<
" staticFucVar " << staticFucVar
<<std::endl;
}