Skip to content

Instantly share code, notes, and snippets.

@hamada-lemois
Created March 16, 2016 14:13
Show Gist options
  • Select an option

  • Save hamada-lemois/012d4b8f2296e54f15ce to your computer and use it in GitHub Desktop.

Select an option

Save hamada-lemois/012d4b8f2296e54f15ce to your computer and use it in GitHub Desktop.
static const string members of struct in class
#include <iostream>
class Character {
public:
struct Direction {
static const std::string Front;
static const std::string Back;
static const std::string Left;
static const std::string Right;
};
};
const std::string Character::Direction::Front = "front";
const std::string Character::Direction::Back = "back";
const std::string Character::Direction::Left = "left";
const std::string Character::Direction::Right = "right";
int main() {
std::cout << Character::Direction::Front << std::endl;
std::cout << Character::Direction::Back << std::endl;
std::cout << Character::Direction::Left << std::endl;
std::cout << Character::Direction::Right << std::endl;
return 0;
}
@hamada-lemois
Copy link
Author

clang++ -std=c++11 hoge.cpp でコンパイル

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment