Skip to content

Instantly share code, notes, and snippets.

@vasalf vasalf/Makefile
Created Dec 6, 2019

Embed
What would you like to do?
Внутренний приватный класс
#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;
}
#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;
};
#include <aclass.hpp>
#include <iostream>
int main() {
A a;
std::cout << a.f() << std::endl;
}
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
You can’t perform that action at this time.