Skip to content

Instantly share code, notes, and snippets.

@tinvaan
Last active September 18, 2018 18:27
Show Gist options
  • Save tinvaan/fa6e76a8c28836da1afe83be4f7b0659 to your computer and use it in GitHub Desktop.
Save tinvaan/fa6e76a8c28836da1afe83be4f7b0659 to your computer and use it in GitHub Desktop.
C++ headers and source description
#include <iostream>
class Foo
{
public:
Foo() {}
void method1()
{
std::cout << "Foo::method1()" << std::endl;
}
void method2()
{
std::cout << "Foo::method2()" << std::endl;
}
};
int main(int argc, char *argv[])
{
Foo f;
f.method1();
f.method2();
return 0;
}
#include <iostream>
class Foo
{
public:
Foo();
void method1();
void method2();
};
Foo::Foo()
{}
void Foo::method1()
{
std::cout << "Foo::method1()" << std::endl;
}
void Foo::method2()
{
std::cout << "Foo::method2()" << std::endl;
}
int main(int argc, char *argv[])
{
Foo f;
f.method1();
f.method2();
return 0;
}
#include <iostream>
#include "foo.h"
Foo::Foo()
{}
void Foo::method1()
{
std::cout << "Foo::method1()" << std::endl;
}
void Foo::method2()
{
std::cout << "Foo::method2()" << std::endl;
}
#pragma once
class Foo
{
public:
Foo();
void method1();
void method2();
};
#include "foo.h"
int main(int argc, char *argv[])
{
Foo f;
f.method1();
f.method2();
return 0;
}
/**
* Program to be compiled using
* $ g++ main.cpp foo.cpp
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment