Skip to content

Instantly share code, notes, and snippets.

@maraigue
Created January 11, 2015 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maraigue/d9a40a3028a4ae8689b1 to your computer and use it in GitHub Desktop.
Save maraigue/d9a40a3028a4ae8689b1 to your computer and use it in GitHub Desktop.
#include <iostream>
class Hoge{
const int v;
public:
Hoge(int x) : v(x * 5) {} // 問題なく動作
//Hoge(int x) { v = x * 5; } // 不可
int value(){ return v; }
};
int main(void){
Hoge h(8);
std::cout << h.value() << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment