-8

I have compilation errors to just simply output a cout message. Below is my code:

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
    char letter = 'a';
    short age = 10;
    int cout = 575;
    long numStars = 985632145;
    float pi = 3.1;
    double price = 89.65;
    string season = "summer";

    cout << "Letter: "<< letter << endl;
    std::cout << "Age: " << age<< endl;
    std::cout << "Cout: " << cout << endl;
    std::cout << "Number Stars: " << numStars << endl;
    std::cout << "Pi: " << pi << endl;
    std::cout << "Price: " << price << endl;
    std::cout << "Season: " << season;


    system("pause");
    return 0;
}

The errors I get are on the line:

cout << "Letter: "<< letter << endl;

I have tried reinstalling VS2015 but that didn't help.

Tas
  • 7,023
  • 3
  • 36
  • 51
  • 4
    Please [edit] this question to provide a [mcve] and include the exact error messages you get (as text, *not* as screenshot). – Baum mit Augen Jun 30 '16 at 01:19
  • 3
    Strongly consider giving [ask] a read over as well. – user4581301 Jun 30 '16 at 01:19
  • 2
    _What_ compilation errors? What's the minimal amount of code you need to reproduce this? No one can help otherwise as there are a plethora of reasons you may be getting errors – Tas Jun 30 '16 at 01:23
  • Well I new to this web page, sorry I can't express the question well. The thing is that VS2015 isn't building properly a simple c++ program of display types of variables i.e, char, int, long, double, float. The problem is using the namespace std. cout << "Letter" is a message and that's my problem VS sends me an error where it says "Letter" – Alex Enginner Jun 30 '16 at 01:43
  • Found a temporary solution and that was to change the projects' properties and where it says 'Character Set' I changed the multibyte Character Set to Unicode Character Set. And the errors disappeared! – Alex Enginner Jun 30 '16 at 02:04
  • @AlexEnginner If you've found a solution, post it as an answer :) Then after 2 days you will be able to accept it as _the answer_ if you wish. – Tim Malone Jun 30 '16 at 02:55

1 Answers1

2

You have a variable of type int called cout - this is not allowed given that you are using namespace std. Change this variable name to something else, and avoid the statement using namespace std.

std::cout is a "reserved type/keyword" so you cannot use it as a variable name.

Community
  • 1
  • 1
sjrowlinson
  • 3,297
  • 1
  • 18
  • 35
  • I don't recall `cout` being reserved and nothing I've seen in a quick looksie says it is, but the rest of this answer is spot on. – user4581301 Jun 30 '16 at 03:57