Hello,
I am using Visual C++ 2008 Express Edition Beta 2 and am trying to learn C++.
I have created my first bit of code, so that i can learn some c++.
Here is my code:
================
// Test C++ Application
#include %26lt;iostream%26gt;
using namespace std;
int main ()
{
int text1, text2;
int message;
text1 = "cout %26lt;%26lt; 'Hello'";
text2 = "cout %26lt;%26lt; 'Everyone'";
message = text1, text2;
cout %26lt;%26lt; message;
return 0;
}
===========
When i try to build the solution, i get the following:
========
------ Build started: Project: Test Application, Configuration: Debug Win32 ------
Compiling...
Test_App.cpp
.\Test_App.cpp(8) : error C2440: '=' : cannot convert from 'const char [16]' to 'int'
There is no context in which this conversion is possible
.\Test_App.cpp(9) : error C2440: '=' : cannot convert from 'const char [19]' to 'int'
There is no context in which this conversion is possible
Build log was saved at "directory"
Test Application - 2 error(s), 0 warning(s)
C++ Build Solution problem?
The problem is that you try to assign a string to an integer variable, try to change the type of text1,text2 and message to a suitable type such as char[] or String .
Reply:Tery this
// Test C++ Application
#include %26lt;iostream%26gt;
using namespace std;
int main ()
{
char* text1, text2;
char* message;
text1 = "cout %26lt;%26lt; 'Hello'";
text2 = "cout %26lt;%26lt; 'Everyone'";
message = text1, text2;
cout %26lt;%26lt; message;
return 0;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment