[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –

Buckys C++ Programming Tutorials – 45 – Member Initializers
by
Tags:
Comments
25 responses to “Buckys C++ Programming Tutorials – 45 – Member Initializers”
-
Thank you 🙂
-
bucky did you create sololearn.com and if not why are they copying your tutorials without rights??
-
thanks men, you save my life.
-
Cant we do it like this ?
Sally :: Sally(int a , int b){
regVar = a ;
constVar = b;
}
Even here we are just intializing the variables, since Sally() is executed the moment an obj is created i dont think it will make a difference. -
what is void sally::print()
-
as regVar is not a constant variable, why we defined this before the paranthesis , can we only define consVar in that manner and regVar under parenthesis?
-
well explained!!
-
I hate Scott who learned at treehouse…..
-
I remember the last 30 seconds!
-
there is a way, have full screen recording and not a cropped one.
-
And guess what, you didn't hear a "pretty cool huh?!"in this tutorial. 😛
-
Honestly, what a STUPID syntax.
-
why are the variables initialised in private?
-
Would it still work if I input:
Sally::Sally(int a, int b) {
regVar = a;
constVar = b;}
-
Why cant initialize in the constructor??? like this..
MyClass::MyClass(int a , int b){
num=a;
constnum=b;
} -
Bucky, I know this may seem obvious but for that long line that wouldn't fit on your screen this code would have prevented that:
void Bella::print(){
cout << "Regular var is: " << regVar << endl;
cout << "Constant var is: " << constVar << endl;
} -
In the class under under "private: ", can't you just say reg Var = 3 . and modify it in the class function[Sally::Sally(int a, int b)]
///////////////////////////////////////////////////////
Like in Sally.hpublic:
Sally(int , int);
private:
int regVar;
const int constVar;
///////////////////////////////////////////////////////
in Sally.cppSally::Sally (int a, int b) : constVar(b) {
regVar = a;
}
///////////////////////////////////////////////////////
and in main.cppmain() {
Sally so(3, 87)
}
//////////////////////////////////////////////////////// -
why are ya defining private variables in the header?
surely that should be defined in the .cpp file.the idea of the header according to previous videos was that the publicly exposed stuff was in there.
this is the first time we've seen variables declared in the header and i don't understand why -
did everything he said to doo and it say reg var and const var not declared.
-
Just a question and what i think , I see this and then realize after all I've learned so far what the hell am I learning. What can I do with all this im looking for game design but i don't know the first thing?
-
Hello,
Error is inside of main, and i create object:
Mateo ma(4 ,50);
ma.print();
I get error at number 4 its say: cannot access private member declared in class 'Mateo'
I just do as in video, just rename my variable and class.
Can't find solution, help… -
–> Word Wrap Setting in CodeBlocks <–
– Go to Edit Menu
– Then Go To Editor Tweaks Option
– And Select Word Wrap.
thanks for ur tutorials bucky. -
You can just press enter after a "<<" and continue typing in the next line. The compiler ignores blank spaces in the code.
EDIT: Just as an example, the two codes are both working:
1/
cout << "Hi << endl;2/
cout
<<
"Hi"
<<
endl
; -
word wrap? use somewhere in your line and press enter. It helps you to continue your code on the next line without using another cout.
-
Does the function that initializes variables need to be named the same thing as the class?
Otherwise, I don't see how this could be written:Sally so (3, 87);
because it doesn't specify the function within the class that initializes the variables
Leave a Reply