Click here to Skip to main content
15,917,859 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
manoharbalu15-May-18 3:48
manoharbalu15-May-18 3:48 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
leon de boer15-May-18 5:50
leon de boer15-May-18 5:50 
GeneralRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Victor Nijegorodov15-May-18 9:57
Victor Nijegorodov15-May-18 9:57 
AnswerRe: To install Visual Studio(2008 Pro,2010 Express and 2013 Express) in the same machine Pin
Joe Woodbury17-May-18 5:55
professionalJoe Woodbury17-May-18 5:55 
QuestionCInternetSession OpenURL Pin
_Flaviu14-May-18 0:34
_Flaviu14-May-18 0:34 
AnswerRe: CInternetSession OpenURL Pin
Jochen Arndt14-May-18 2:01
professionalJochen Arndt14-May-18 2:01 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu14-May-18 2:24
_Flaviu14-May-18 2:24 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt14-May-18 2:29
professionalJochen Arndt14-May-18 2:29 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu14-May-18 2:34
_Flaviu14-May-18 2:34 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu14-May-18 23:00
_Flaviu14-May-18 23:00 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu14-May-18 23:07
_Flaviu14-May-18 23:07 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt15-May-18 0:01
professionalJochen Arndt15-May-18 0:01 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu15-May-18 0:21
_Flaviu15-May-18 0:21 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt15-May-18 0:31
professionalJochen Arndt15-May-18 0:31 
GeneralRe: CInternetSession OpenURL Pin
_Flaviu15-May-18 0:44
_Flaviu15-May-18 0:44 
GeneralRe: CInternetSession OpenURL Pin
Jochen Arndt15-May-18 1:21
professionalJochen Arndt15-May-18 1:21 
AnswerRe: CInternetSession OpenURL Pin
Randor 15-May-18 9:46
professional Randor 15-May-18 9:46 
QuestionWhy can't variables be declared in a switch statement Pin
tracyhe12313-May-18 20:34
tracyhe12313-May-18 20:34 
AnswerRe: Why can't variables be declared in a switch statement Pin
Richard MacCutchan13-May-18 20:58
mveRichard MacCutchan13-May-18 20:58 
Questionwhy passing argument by reference(&ref) in a template function shows error ? but works fine if arguments passed by pointer(*ptr) ? Pin
Tarun Jha13-May-18 1:46
Tarun Jha13-May-18 1:46 
AnswerRe: why passing argument by reference(&ref) in a template function shows error ? but works fine if arguments passed by pointer(*ptr) ? Pin
CPallini13-May-18 2:56
mveCPallini13-May-18 2:56 
GeneralRe: why passing argument by reference(&ref) in a template function shows error ? but works fine if arguments passed by pointer(*ptr) ? Pin
Tarun Jha26-May-18 9:50
Tarun Jha26-May-18 9:50 
GeneralRe: why passing argument by reference(&ref) in a template function shows error ? but works fine if arguments passed by pointer(*ptr) ? Pin
CPallini26-May-18 10:53
mveCPallini26-May-18 10:53 
Questionproblem encountered by calling constructors explicitly. Pin
Tarun Jha11-May-18 10:20
Tarun Jha11-May-18 10:20 
here in the below program i have tried to pass the values of 1d matrix to the object of class Vector by using constructor explicit call.

#include <iostream>
using namespace std;

const int size = 3;
class Vector {
    int *v;

public:
    Vector(){
        v = new int[size];
        for(int i=0; i<size; i++)
            v[i] = 0;
    }
    Vector(int *a){
        for(int i=0; i<size; i++){
            v[i] = a[i] ;
        }

        //display();
    }
    int operator * (Vector &y){
        int sum=0;
        for(int i=0; i<size; i++)
            sum += this->v[i] * y.v[i] ;
        return sum;
    }

    void display(){
        for(int i=0; i<size; i++)
            cout << v[i] << " ";
        cout << endl;
    }
};

int main(){
    int x[3] = {1, 2, 3};
    int y[3] = {6, 3, 9};
    Vector v1, v2;

    v1 = y;
    v2 = x;

    cout << "v1 = ";
    v1.display();

    cout << "v2 = ";
    v2.display();

    cout << "v1 x v2 = " << v1 * v2 << endl ;
    return 0;
}


Quote:
cout << "v1 = ";
v1.display();

cout << "v2 = ";
v2.display();

the above portion of code doesn't works as expected it gives,

Output:

Quote:

6 3 9
6 3 9
v1 = 6 3 9
v2 = 6 3 9
v1 x v2 = 126


Expected:
Quote:
Quote:

1 2 3
6 3 9
v1 = 1 2 3
v2 = 6 3 9
v1 x v2 = 39


Thank you
AnswerRe: problem encountered by calling constructors explicitly. Pin
Joe Woodbury11-May-18 11:39
professionalJoe Woodbury11-May-18 11:39 

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.