Skip to content

Instantly share code, notes, and snippets.

@Dubhead
Created August 2, 2011 05:57
Show Gist options
  • Save Dubhead/1119657 to your computer and use it in GitHub Desktop.
Save Dubhead/1119657 to your computer and use it in GitHub Desktop.
#include <iostream>
class Foo {
public:
Foo() {}
void say() {
std::cout << data_ << std::endl;
}
private:
int data_; // uninitialized!
};
int main()
{
Foo foo;
foo.say();
return 0;
}
/*
% cppcheck --enable=all foo.cpp
Checking foo.cpp...
[foo.cpp:5]: (warning) Member variable 'Foo::data_' is not initialized in the constructor.
%
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment