Created
December 6, 2019 22:19
-
-
Save vasalf/d2d4447038d4e4a6a052cb5da8c96cfc to your computer and use it in GitHub Desktop.
Внутренний приватный класс
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <aclass.hpp> | |
A::A() { | |
x = 30; | |
} | |
int A::f() { | |
x += 10; | |
b.f(); | |
return x + b.getX(); | |
} | |
A::B::B() { | |
x = 138; | |
} | |
void A::B::f() { | |
x++; | |
} | |
int A::B::getX() { | |
return x; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
class A { | |
private: | |
class B { | |
public: | |
B(); | |
void f(); | |
int getX(); | |
private: | |
int x; | |
}; | |
public: | |
A(); | |
int f(); | |
private: | |
B b; | |
int x; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <aclass.hpp> | |
#include <iostream> | |
int main() { | |
A a; | |
std::cout << a.f() << std::endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: main | |
bin: | |
mkdir bin | |
bin/aclass.o: src/aclass.cpp | bin | |
g++ -c -g -Iinclude -std=c++11 src/aclass.cpp -o bin/aclass.o | |
bin/main.o: src/main.cpp | bin | |
g++ -c -g -Iinclude -std=c++11 src/main.cpp -o bin/main.o | |
main: bin/aclass.o bin/main.o | |
g++ bin/aclass.o bin/main.o -o main | |
clean: | |
rm -Rf bin main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment