Click here to Skip to main content
13,793,266 members

C / C++ / MFC

 
GeneralRe: error C2143: syntax error: missing ':' before 'constant' Pin
Peter_in_278027-Mar-18 19:13
professionalPeter_in_278027-Mar-18 19:13 
GeneralRe: error C2143: syntax error: missing ':' before 'constant' Pin
ForNow28-Mar-18 15:50
memberForNow28-Mar-18 15:50 
GeneralRe: error C2143: syntax error: missing ':' before 'constant' Pin
Victor Nijegorodov27-Mar-18 22:18
memberVictor Nijegorodov27-Mar-18 22:18 
GeneralRe: error C2143: syntax error: missing ':' before 'constant' Pin
ForNow28-Mar-18 1:31
memberForNow28-Mar-18 1:31 
AnswerRe: error C2143: syntax error: missing ':' before 'constant' Pin
Richard MacCutchan27-Mar-18 23:08
protectorRichard MacCutchan27-Mar-18 23:08 
AnswerRe: error C2143: syntax error: missing ':' before 'constant' Pin
Jochen Arndt27-Mar-18 23:41
mvpJochen Arndt27-Mar-18 23:41 
GeneralRe: error C2143: syntax error: missing ':' before 'constant' The Hercules makefile has V1,V2,V3,V4 Pin
ForNow28-Mar-18 16:44
memberForNow28-Mar-18 16:44 
Questionproblem understanding a functionality of constructor. Pin
Tarun Jha27-Mar-18 5:39
memberTarun Jha27-Mar-18 5:39 
i was going through a article about friend function and then in i came across this code:

#include <iostream>
using namespace std;

class Distance
{
    private:
        int meter;
    public:
        Distance(): meter(0) { }
        //friend function
        friend int addFive(Distance);
};

// friend function definition
int addFive(Distance d)
{
    //accessing private data from non-member function
    d.meter += 5;
    return d.meter;
}

int main()
{
    Distance D;
    cout<<"Distance: "<< addFive(D);
    return 0;
}


in the above code what is
Quote:
Distance(): meter(0) { }


and how is a object of class distance is able to access a private member ?
Quote:
int addFive(Distance d)
{
//accessing private data from non-member function
d.meter += 5;
return d.meter;
}


Thank you.
AnswerRe: problem understanding a functionality of constructor. Pin
Jochen Arndt27-Mar-18 5:55
mvpJochen Arndt27-Mar-18 5:55 
AnswerRe: problem understanding a functionality of constructor. Pin
Richard MacCutchan27-Mar-18 6:18
protectorRichard MacCutchan27-Mar-18 6:18 
AnswerRe: problem understanding a functionality of constructor. Pin
CPallini27-Mar-18 6:36
mvpCPallini27-Mar-18 6:36 
QuestionHackerrank:Down to Zero problem Pin
SrinivasaRamanujan25-Mar-18 11:23
memberSrinivasaRamanujan25-Mar-18 11:23 
AnswerRe: Hackerrank:Down to Zero problem Pin
David Crow25-Mar-18 16:41
memberDavid Crow25-Mar-18 16:41 
QuestionIn type conversion of 2 different classes can i convert both ways ? Pin
Tarun Jha25-Mar-18 6:14
memberTarun Jha25-Mar-18 6:14 
AnswerRe: In type conversion of 2 different classes can i convert both ways ? Pin
Victor Nijegorodov25-Mar-18 9:07
memberVictor Nijegorodov25-Mar-18 9:07 
GeneralRe: In type conversion of 2 different classes can i convert both ways ? Pin
Tarun Jha26-Mar-18 0:26
memberTarun Jha26-Mar-18 0:26 
AnswerRe: In type conversion of 2 different classes can i convert both ways ? Pin
CPallini25-Mar-18 11:50
mvpCPallini25-Mar-18 11:50 
GeneralRe: In type conversion of 2 different classes can i convert both ways ? Pin
Tarun Jha26-Mar-18 0:25
memberTarun Jha26-Mar-18 0:25 
GeneralRe: In type conversion of 2 different classes can i convert both ways ? Pin
CPallini26-Mar-18 1:18
mvpCPallini26-Mar-18 1:18 
QuestionAdding two matrix objects and assigning the result to third object using overloaded operators ? Pin
Tarun Jha24-Mar-18 9:19
memberTarun Jha24-Mar-18 9:19 
AnswerRe: Adding two matrix objects and assigning the result to third object using overloaded operators ? Pin
Victor Nijegorodov24-Mar-18 9:35
memberVictor Nijegorodov24-Mar-18 9:35 
GeneralRe: Adding two matrix objects and assigning the result to third object using overloaded operators ? Pin
Tarun Jha24-Mar-18 11:06
memberTarun Jha24-Mar-18 11:06 
AnswerRe: Adding two matrix objects and assigning the result to third object using overloaded operators ? Pin
Richard MacCutchan24-Mar-18 22:13
protectorRichard MacCutchan24-Mar-18 22:13 
GeneralRe: Adding two matrix objects and assigning the result to third object using overloaded operators ? Pin
Tarun Jha25-Mar-18 6:08
memberTarun Jha25-Mar-18 6:08 
GeneralRe: Adding two matrix objects and assigning the result to third object using overloaded operators ? Pin
Richard MacCutchan25-Mar-18 6:32
protectorRichard MacCutchan25-Mar-18 6:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.181207.3 | Last Updated 10 Dec 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid