Not a prob :) Could you please mark this as solved?
also, in your original code you used: system("PAUSE");
, I remember reading that it's not a good practice to use system
i suggest using sleep()
declared in Windows.h :)
Not a prob :) Could you please mark this as solved?
also, in your original code you used: system("PAUSE");
, I remember reading that it's not a good practice to use system
i suggest using sleep()
declared in Windows.h :)
2. Why address of a and b are same.
They are not, i ran it on my computer and i get 2 different addresses
3. If I use copy constructor here, then the first line of main() is giving error
Look at my answer to #5
4. Constructor is getting called for object b which it should be, but destructor is getting called for object a.
I don't think so, I removed the function fun() and left only a, and it gave me both destructor/constructor messages...i think the des/con aren't being called on B :?
5)Why am i not allowed to create a copy-constructor in this class?
Because it should be like this:
class A{
int i;
public:
A(){
cout<<"default constructor\n";
}
~A(){
cout<<"default destrutor\n";
}
A(A& obj);
};
and this:
A::A(A& obj)
{
i=obj.i;
cout<<"copy constructor\n";
};
Here, your code should be:
#include <iostream>
using namespace std;
class A{
int i;
public:
A(){
cout<<"default constructor\n";
}
~A(){
cout<<"default destrutor\n";
}
};
A fun(){
A b;
cout<<" address of b = "<<&b<<endl;
return b;
}
int main(){
A a;
fun();
cout<<" address of a = " << &a<<endl;
return 0;
}
First lemme say,So far so good. Whether or not you need a DB for this application depends on its complexity. If this is just a little thing, I wouldn't bother, but if this a full scale, or extremely complex situation, then look to a database.
To check and see if the two string matches you could do something like this(I wrote this example in C++, but you could do this in C#):
/*** Comparing two strings ***/
#include <iostream>
using namespace std;
int main()
{
string a="Hello";
string b="wasup";
if(b == a)
{
cout << "they are the same";
}
else {cout << "they are different";}
return 0;
}
hope i helped :)