0

this my first c++ project by using classes and i face this problem error C3867

my main code is

#include <string>
#include <iostream>
#include "Car.h"
int main() {
  Car c1;
  c1.setMaker("Honda");
  c1.setModel(2018);
  cout << "This Car Made By" << c1.getMaker << "\n";
  cout << "This Car Model" << c1.getModel << "\n";
}

the header is

#pragma once
#include <string>
using namespace std;
class Car {
 private:
  string maker;
  int model;

 public:
  void setMaker(string m);
  string getMaker();
  void setModel(int m);
  int getModel();

the cpp is

#include "Car.h"

void Car::setMaker(string l) { maker = l; }

string Car::getMaker() { return maker; }

void Car::setModel(int m) { model = m; }

int Car::getModel() { return model; }

and this is the error message: error C3867: 'Car::getMaker': non-standard syntax; use '&' to create a pointer to member

i've tried everything i know as a beginner but i can't make it work :(

Aykhan Hagverdili
  • 28,141
  • 6
  • 41
  • 93
Leo Adel
  • 13
  • 2
  • 5
    `c1.getMaker` that's not how you call a function. Add `()` to the end. Calling functions is a rather basic language feature, I suggest using a good book or tutorial to learn the language. – Blaze Jun 27 '19 at 08:41
  • 2
    @Blaze Such comments are best accompanied with a link to our [list of good C++ books](https://stackoverflow.com/q/388242/1782465). – Angew is no longer proud of SO Jun 27 '19 at 08:46
  • Admittedly the error message might appear somewhat puzzling to a beginner. Change `c1.getMaker` to `c1.getMaker()`. – Jabberwocky Jun 27 '19 at 09:00

1 Answers1

3

You need to call functions with a parameter list at the end, even if that list is empty.

E.g

c1.getMaker is the address to the getMaker function

c1.getMaker() actually calls the function

Prodigle
  • 1,757
  • 12
  • 23