What's wrong with my static topStock method? It takes in a reference to Stock s and Stock t. Shouldn't it return a copy of s or t?
error: expected primary-expression before '.' token|
#include <iostream>
using namespace std;
class Stock {
public:
Stock() : x(0){ }
Stock(int val) : x(val){}
void display() const;
static Stock topStock(const Stock& s, const Stock& t) {
if (s.x > t.x)
return s;
else
return t;
}
int x;
};
void Stock::display() const
{
std::cout << this->x;
}
int main()
{
Stock s(9);
Stock y(8);
Stock z = Stock.topStock(s, y);
return 0;
}