Hey guys,
I was just wandering, why is an alias created like this:
Howcome this does not assign the value of a, currently 0 to the address of b?
Howcome to assign an alias it is not done like this:
This makes more sence to me anyway as the address one one gets assigned the address of the other?
Also another wee problem i am having i am trying to figure out how you can assign a string literal to a character array which is a member of a class. I tried it in the code below but it returns an error below. Could anyone show me how to do this?
I was just wandering, why is an alias created like this:
Rich (BB code):
int a = 0;
int &b = a;
Howcome to assign an alias it is not done like this:
Rich (BB code):
int a = 0;
int &b = &a;
Also another wee problem i am having i am trying to figure out how you can assign a string literal to a character array which is a member of a class. I tried it in the code below but it returns an error below. Could anyone show me how to do this?
Rich (BB code):
#include <iostream>
using namespace std;
int main()
{
struct test
{
char a[50];
};
test stest;
stest.a = "hello.";
return 0;
}
Rich (BB code):
1>------ Build started: Project: Test7, Configuration: Debug Win32 ------
1>Compiling...
1>Test7.cpp
1>z:\college\year2\programming\programs\test7\test7\test7.cpp(13) : error C2440: '=' : cannot convert from 'const char [7]' to 'char [50]'
1> There is no context in which this conversion is possible
1>Build log was saved at "file://z:\College\Year2\Programming\Programs\Test7\Test7\Debug\BuildLog.htm"
1>Test7 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========