During refactoring my code, it took me some time before I realized why I was having the compilation errors.
class MyDrawingArea : public Gtk::DrawingArea { public: // private: Sound* s = nullptr; }; MyDrawingArea::MyDrawingArea(Sound* ss) : s {ss} { nch = s->get_channels(); // O.K. }
You agree with me that the short names, such as s or ss, are elegant than longer ones, but:
bool MyDrawingArea::on_draw(const Cairo::RefPtr<Cairo::Context> &cr) { s->asound_read(); // O.K. // many lines here for(int ix=0;ix<waveform_x;ix++) { cr->line_to(ix, s->audio_signal[ix];) // Error! }
I first thought it was OK with member functions, but not with data members, and I was checking only class definitions.
Actually, it was due to the following lines moved from another place and inserted at //many lines here:
//{ /* braces are here before, but deleted later to beautify (!) the code */ unsigned char *s; s= buf; for(i=0;i<buf_len;i++) { cout << *s++; } // }
http://www.stroustrup.com/bs_faq2.html#Hungarian
https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Variable_Names