troubleshooting Question

[noob][c++] is this a declaration or a constructor?

Avatar of Troudeloup
Troudeloup asked on
Programming Languages-OtherC++
10 Comments9 Solutions403 ViewsLast Modified:
isn't this part the constructor to make an object from the class?

CRectangle rect



what is this part below?


void CRectangle::set_values (int a, int b) {
  x = a;
  y = b;
}




// classes example
#include <iostream>
using namespace std;

class CRectangle {
    int x, y;
  public:
    void set_values (int,int);
    int area () {return (x*y);}
};

void CRectangle::set_values (int a, int b) {
  x = a;
  y = b;
}

int main () {
  CRectangle rect;
  rect.set_values (3,4);
  cout << "area: " << rect.area();
  return 0;
}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 9 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 9 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros