if/else multiple question statements

I'm trying to construct a program that asks three separate questions, and then outputs whether the answer was correct or not. The answer is not to be case-sensitive. I keep on getting 4 types of errors when I compile it though:

c2784 - 'declaration' : could not deduce template argument for 'type' from 'type'
c2780 - A function template has too few arguments.
c2228 - left of '.identifier' must have class/struct/union
c2446 - 'operator' : no conversion from 'type1' to 'type2'

I have an issue grasping the whole function/argument concept, so can somebody give me some advice? Here is my code so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <algorithm> 
#include <iostream> 
#include <string> 
using namespace std;
#include <cctype> 

class toLower {public: char operator()(char c) const {return tolower(c);}}; 
  
int main() 
{ 
  string city; 
  cout << "In what city was Apple Inc. established?: "; 
  getline(cin, city); 
  
  transform(city.begin(), city.end(), city.begin(), toLower()); 
  
  if (city == "cupertino") {
    cout << "Correct!" << endl; }
  else {
    cout << "Incorrect."  << endl; }

    cout << endl << endl;


  string lastName; 
  cout << "What is the last name of Steve Jobs' biological father?: "; 
  getline(cin, lastName); 
  
  transform(lastName.begin(), lastName.end(), lastName.begin(), toLower()); 
  
  if (lastName == "jandali") {
    cout << "Correct!" << endl;} 
  else {
    cout << "Incorrect."  << endl; }

  cout << endl << endl;

  int year; 
  cout << "In which year was Apple Computer Inc. established?: "; 
  getline(1000, 10); 
  
  transform(year.begin(), year.end(), year.begin(), toLower()); 
  
  if (year == "1976") {
    cout << "Correct!" << endl; }
  else {
    cout << "Incorrect."  << endl; }

  cout << endl << endl;
 



  
  return 0; 
}



Your help will be appreciated :)
getline(1000, 10);
This makes no sense. getline does not take two int values as parameters.


year.begin() year is an int. An int does not have member functions.


year.end() year is an int. An int does not have member functions.

(year == "1976")
You are comparing an int, on the left, with a const char*, on the right. This makes no sense.
Thanks, it works now :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <algorithm> 
#include <iostream> 
#include <string> 
using namespace std;
#include <cctype> 

class toLower {public: char operator()(char c) const {return tolower(c);}}; 
  
int main() 
{ 
  string city; 
  cout << "In what city was Apple Inc. established?: "; 
  getline(cin, city); 
  
  transform(city.begin(), city.end(), city.begin(), toLower()); 
  
  if (city == "cupertino") {
    cout << "Correct!" << endl; }
  else {
    cout << "Incorrect."  << endl; }

    cout << endl << endl;


  string lastName; 
  cout << "What is the last name of Steve Jobs' biological father?: "; 
  getline(cin, lastName); 
  
  transform(lastName.begin(), lastName.end(), lastName.begin(), toLower()); 
  
  if (lastName == "jandali") {
    cout << "Correct!" << endl;} 
  else {
    cout << "Incorrect."  << endl; }

  cout << endl << endl;

  int year; 
  cout << "In which year was Apple Computer Inc. established?: "; 
  cin >> year; 
   
  
  if (year == 1976) {
    cout << "Correct!" << endl; }
  else {
    cout << "Incorrect."  << endl; }

  cout << endl << endl;
 



  
  return 0; 
}
Topic archived. No new replies allowed.