C++ left of getter() must have class/struct/union -


i trying exercise on class inheritance in c++. main idea have point class (defining point 2 coordinates) , have different shapes (such rectangle, square, triangle ...etc)

my point class has getters called getx() , gety(), both return double values.

in of shape classes (rectangle, square, triangle) have print method prints class members console. in method need x , y of instance of point. problem following compile error when :

error c2228: left of '.getx' must have class/struct/union 

here pastebins rest of code :

point class header : http://pastebin.com/va29dtke

point class cpp file : http://pastebin.com/e8gkrsht

rectangle class header : http://pastebin.com/pxnxx18q

rectangle class cpp file: http://pastebin.com/r09vgfdb

the issue occurs on lines 18 , 19 in rectangle class cpp file. in advance :)

 point rectangle::origin(double, double); 

is function takes 2 doubles, therefore have call like:

double rectangle::draw() {     std::cout << "rectangle membembers:\n";     //x = this->origin.getx();     std::cout << this->width;     std::cout << this->height;     std::cout << this->origin(0, 0).getx(); // here     std::cout << this->origin(0, 0).gety(); // here } 

you wanted declare , use as:

class rectangle : polygon { private:     point origin; };  rectangle::rectangle(double x, double y, double width, double height)  : origin(x, y) {     this->width = width;     this->height= height; } 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -