This file contains hidden or 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
Class inheritance | BaseClass visibility | Inheriting class visibility | |
---|---|---|---|
public | public | public | |
protected | protected | ||
private | none | ||
protected | public | protected | |
protected | protected | ||
private | none | ||
private | public | private |
This file contains hidden or 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 <iostream> | |
#include <string> | |
class Singleton { | |
public: | |
// Returns a reference to static instance of this class | |
static Singleton& instance() { | |
static Singleton instance; | |
return instance; | |
} |
This file contains hidden or 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 <iostream> | |
#include <string> | |
#include <map> | |
class Mapleton { | |
public: | |
// Returns a reference to static instance of this class | |
// based on provided string identifier | |
static Mapleton& instance(const std::string& id) { | |
static std::map<std::string, Mapleton> instances; |
This file contains hidden or 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
find impl/ -iname *.hpp -o -iname *.cpp -o -iname *.h | xargs clang-format -i -style=file |
This file contains hidden or 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 <iostream> | |
class HiMyNameIs { | |
public: | |
void SlimShady() { std::cout << "Hi! My name is (what?)" << std::endl; } | |
}; | |
void HiMyNameIs() { | |
std::cout << "My name is who?" << std::endl; | |
} |
This file contains hidden or 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
/// object_pool.hpp | |
#include <functional> | |
#include <iostream> | |
#include <memory> | |
#include <stack> | |
#include <tuple> | |
// Base class for all poolable objects | |
class PoolableObject { |
This file contains hidden or 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 <iostream> | |
#include <stdexcept> | |
class Note { | |
public: | |
int PublicField; | |
std::string GetPrivateField() { | |
return privateField; | |
} | |
void SetPrivateField(const std::string& field) { |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"os" | |
"errors" | |
) | |
func NewNote(field string) (Note, error) { | |
inst := Note{} |
This file contains hidden or 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
class Session { | |
public String getCustomerName() { | |
// Some checks and throws exception if session not started | |
throw new SessionNotStartedException(); | |
} | |
public static Session getCurrentSession() { | |
return new Session(); | |
} | |
} |
This file contains hidden or 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
class Session { | |
public String getCustomerName() { | |
// Some checks and throws exception if session not started | |
throw new SessionNotStartedException(); | |
} | |
public static Session getCurrentSession() { | |
return new Session(); | |
} | |
} |