Click here to Skip to main content
15,916,951 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to map a matrix index to a memory location Pin
Daniel Pfeffer29-Mar-18 5:06
professionalDaniel Pfeffer29-Mar-18 5:06 
QuestionWhat is the best tool to find C++ Memory issues Pin
ptr_Electron29-Mar-18 1:06
ptr_Electron29-Mar-18 1:06 
AnswerRe: What is the best tool to find C++ Memory issues Pin
Leif Simon Goodwin29-Mar-18 1:28
Leif Simon Goodwin29-Mar-18 1:28 
GeneralRe: What is the best tool to find C++ Memory issues Pin
ptr_Electron30-Mar-18 10:12
ptr_Electron30-Mar-18 10:12 
QuestionMemory allocated out side of try and Delete in finally Pin
ptr_Electron28-Mar-18 23:46
ptr_Electron28-Mar-18 23:46 
AnswerRe: Memory allocated out side of try and Delete in finally Pin
Jochen Arndt29-Mar-18 0:17
professionalJochen Arndt29-Mar-18 0:17 
GeneralRe: Memory allocated out side of try and Delete in finally Pin
ptr_Electron29-Mar-18 1:05
ptr_Electron29-Mar-18 1:05 
GeneralRe: Memory allocated out side of try and Delete in finally Pin
Jochen Arndt29-Mar-18 1:44
professionalJochen Arndt29-Mar-18 1:44 
Questionerror C2143: syntax error: missing ':' before 'constant' Pin
ForNow27-Mar-18 15:53
ForNow27-Mar-18 15:53 
QuestionRe: error C2143: syntax error: missing ':' before 'constant' Pin
David Crow27-Mar-18 16:47
David Crow27-Mar-18 16:47 
AnswerRe: error C2143: syntax error: missing ':' before 'constant' Pin
ForNow27-Mar-18 16:52
ForNow27-Mar-18 16:52 
GeneralRe: error C2143: syntax error: missing ':' before 'constant' Pin
Peter_in_278027-Mar-18 18:13
professionalPeter_in_278027-Mar-18 18:13 
GeneralRe: error C2143: syntax error: missing ':' before 'constant' Pin
ForNow28-Mar-18 14:50
ForNow28-Mar-18 14:50 
GeneralRe: error C2143: syntax error: missing ':' before 'constant' Pin
Victor Nijegorodov27-Mar-18 21:18
Victor Nijegorodov27-Mar-18 21:18 
GeneralRe: error C2143: syntax error: missing ':' before 'constant' Pin
ForNow28-Mar-18 0:31
ForNow28-Mar-18 0:31 
AnswerRe: error C2143: syntax error: missing ':' before 'constant' Pin
Richard MacCutchan27-Mar-18 22:08
mveRichard MacCutchan27-Mar-18 22:08 
AnswerRe: error C2143: syntax error: missing ':' before 'constant' Pin
Jochen Arndt27-Mar-18 22:41
professionalJochen Arndt27-Mar-18 22:41 
GeneralRe: error C2143: syntax error: missing ':' before 'constant' The Hercules makefile has V1,V2,V3,V4 Pin
ForNow28-Mar-18 15:44
ForNow28-Mar-18 15:44 
Questionproblem understanding a functionality of constructor. Pin
Tarun Jha27-Mar-18 4:39
Tarun Jha27-Mar-18 4:39 
AnswerRe: problem understanding a functionality of constructor. Pin
Jochen Arndt27-Mar-18 4:55
professionalJochen Arndt27-Mar-18 4:55 
AnswerRe: problem understanding a functionality of constructor. Pin
Richard MacCutchan27-Mar-18 5:18
mveRichard MacCutchan27-Mar-18 5:18 
AnswerRe: problem understanding a functionality of constructor. Pin
CPallini27-Mar-18 5:36
mveCPallini27-Mar-18 5:36 
QuestionHackerrank:Down to Zero problem Pin
SrinivasaRamanujan25-Mar-18 10:23
SrinivasaRamanujan25-Mar-18 10:23 
AnswerRe: Hackerrank:Down to Zero problem Pin
David Crow25-Mar-18 15:41
David Crow25-Mar-18 15:41 
QuestionIn type conversion of 2 different classes can i convert both ways ? Pin
Tarun Jha25-Mar-18 5:14
Tarun Jha25-Mar-18 5:14 
i want to make a program that can convert from class a type to class b & vice versa..
i already made a program that does one type of conversion..

//define 2 classes polar & rectangle to represent points int the polar & rectanglular system.
#include <iostream>
#include <cmath>
using namespace std;

class Polar;

//====================================================
class Rectangle{
    float length, bredth;
public:
    Rectangle(){}
    Rectangle(float ,float);

    /*
      operator Polar(){
        Polar temp;
        float a = atan(length/bredth), r = sqrt(x*x + y*y);
        temp.getAngle(a);
        temp.getRadius(r);

        return(temp);
    }
    */

    int getLength(){return(length);}
    int getBredth(){return(bredth);}
    void putLength(float x){length = x;}
    void putBredth(float y){bredth = y;}

    void putData(){cout<<"Length : "<<length<<"\tBreadth : "<<bredth<<endl;}
    ~Rectangle(){}
};

Rectangle::Rectangle(float x, float y){
    length = x;
    bredth = y;
}

//====================================================

class Polar{
    float angle, rad;
public:

    Polar(){}
    Polar(float , float);

    operator Rectangle(){
        Rectangle temp;
        float l = rad*cos(angle), b =rad*sin(angle) ;
        temp.putLength(l);
        temp.putBredth(b);

        return(temp);
    }

    int getAngle(){return(angle);}
    int getRadius(){return(rad);}
    void putData(){cout<<"Angle : "<<angle<<"\tRadius : "<<rad<<endl;}
    ~Polar(){}
};

Polar::Polar(float x, float y){
    angle = x;
    rad = y;
}

// Rectangle::operator Polar(){
//     Polar temp;
//     float a = atan(length/bredth), r = sqrt(x*x + y*y);
//     temp.getAngle(a);
//     temp.getRadius(r);
//
//     return(temp);
// }
//===========================================================

int main(){
    Rectangle r1(40, 20.23);
    Polar p1(120, 25);

    r1 = p1;
    r1.putData();

    //p1 = r1;
    //p1.putData();

    return 0;

}


as in the above code i have converted class Polar to class Rectangle, but i also want to have a conversion of class Rectangle to class Polar.

Thank you

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.