|
Please tell me Difference between "C structure" and "C++ structure".
|
|
|
|
|
The variables in C structure are by default public but in C++ they are private
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
is it true that constructor will be called for class but there will be no constructor for the structure
|
|
|
|
|
Structures don't have constructors and how can they be called if they don't exist.
Yes but still what you say is correct. It would be better to initialize the member's of the structure somewhere(more preferrably the constructor of the class) before using them.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
We may have a Constructer's for C++ Structures(look the Following code)
C++ Structure's can be initialized/copied by overloading the Assignment Operator Like following
struct Mypoint
{
int x,y;
Mypoint() : x(0),y(0){};
const Mypoint &operator = (const Mypoint &me)
{
x=me.x;
y=me.y;
return *this;
};
Knock out 'T' from CAN'T ,
You 'CAN' if you think you 'CAN'
|
|
|
|
|
_AnShUmAn_ wrote: It would be better to initialize the member's of the structure
you can create Construtor in Structure, see the example i have quoted in post above you!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
NiLeSh KoRpE wrote: there will be no constructor for the structure
Have a try!
#include<stdio.h>
#include <malloc.h>
struct ab
{
ab()
{
printf("alok");
}
};
main()
{
ab a;
int *hello;
printf("Hi, Enter any value > ");
hello=(int*)malloc(sizeof(int));
scanf("%d",hello);
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
_AnShUmAn_ wrote: The variables in C structure are by default public but in C++ they are private
have you tried that?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Ok, I tried your code.
Its working fine.
Thanks for the update and clarification.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
_AnShUmAn_ wrote: Thanks for the update and clarification.
It's OK,I learn a lot while dicussing with you!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi !!!
YOu haven't right.
By !!!
-:KNOX:-
|
|
|
|
|
|
C allows struct, union, and enum types to be declared within function prototype scope, e.g.:
extern void foo(const struct info { int typ; int sz; } *s);
int bar(struct point { int x, y; } pt)
{ ... }
C also allows structure types to be declared as function return types, as in:
extern struct pt { int x; } pos(void);
C++ does not allow either of these, since the scope of the structure declared in this fashion does not extend outside the function declaration or definition, making it impossible to define objects of that structure type which could be passed as arguments to the function or to assign function return values into objects of that type.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Hi
I have image, that changes its position for every 1 sec.like a progress bar. Here I am drwing it using TransparentBlt() here the top position is -x. Now I am not able to erase the top -x portion. If I do InvalidateRect(), whole main window flickers. How can this be resolved?
|
|
|
|
|
WM_NCPAINT[^]
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
Non client area meant as out side the client area of that child window, but it is a part of the main window client area.
|
|
|
|
|
Can anybody please let me know in brief (if possible kindly give link or Example) Early and late binding VC++/C++.
|
|
|
|
|
|
while iam trying to debug my project iam getting this message.
'C:\....\....\ xxx.exe' does not contain debugging information.
Press Ok to continue.
what might be the reason ?
And my project is always crashing while debugging.
can any body help regarding this.
|
|
|
|
|
Can you be more specific exactly
whitesky
|
|
|
|
|
Krishnatv wrote: 'C:\....\....\ xxx.exe' does not contain debugging information.
You are running the Release Build
Krishnatv wrote: And my project is always crashing while debugging.
Crashing is usually caused by bugs.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
You are running the Release Build:
ya IAm Running Release Build.
|
|
|
|
|
Krishnatv wrote: ya IAm Running Release Build.
I know, I already told you that.
Maybe... I don't know I'm just spit-balling here, if you want to debug you should run the debug build!
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
Krishnatv wrote: And my project is always crashing while debugging.
at which point of code or file!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
can i use random shuffle function in MFC application coding...i tried to use but it is not working...if anyone knows how to apply it please tell me..
<code>// coneverterDlg.cpp : implementation file
//
void CConeverterDlg::OnEnter()
{
// TODO: Add your control notification handler code here
CString str;
// char str[13];
cEdit.GetWindowText (str);
//AfxMessageBox(myStr);
//tmStart = time(0);
CTime time=CTime::GetCurrentTime ();
CString strttime= time.Format ("%Y%m%D%H%M%S");
cEdit2.SetWindowText (strttime+"\n");//;(str)
cEdit2.SetWindowText (strttime+"\n");
string line(str);
//line.c_str (),100);
//fin.open("data.txt");
// cout << str<<endl;
for (int i=0; i<500; ++i)
{
random_shuffle(line.begin(), line.end());
// File << "Randomised: " << line << endl;
// File << " : " << line << endl;
// File << " : " << line << endl;
// File << " : " << line << endl;
// File << " "<< endl;
// File << "Single Row: " << s << " " << s << " " << s <<" " << s << endl;
// File << " "<< endl;
CString cStr(line.c_str ());
cEdit1.SetWindowText ( cStr + "\n");
cEdit1.SetWindowText ("Randomised: "+ cStr + "\n");
//tmEnd = time(0);
}
CTime time1=CTime::GetCurrentTime ();
CString strtti= time1.Format ("%Y%m%D%H%M%S");
cEdit1.SetWindowText (str);
cEdit1.SetWindowText (strtti+"\n");
//cout << tmEnd-tmStart << " seconds " << endl;
}
</code>
-- modified at 2:25 Thursday 18th May, 2006.." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CConeverterDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CConeverterDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CConeverterDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CConeverterDlg::OnEnter()
{
// TODO: Add your control notification handler code here
CString str;
// char str[13];
cEdit.GetWindowText (str);
//AfxMessageBox(myStr);
//tmStart = time(0);
CTime time=CTime::GetCurrentTime ();
CString strttime= time.Format ("%Y%m%D%H%M%S");
cEdit2.SetWindowText (strttime+"\n");//;(str)
cEdit2.SetWindowText (strttime+"\n");
string line(str);
//line.c_str (),100);
//fin.open("data.txt");
// cout << str<<endl;
for (int i=0; i<500; ++i)
{
random_shuffle(line.begin(), line.end());
// File << "Randomised: " << line << endl;
// File << " : " << line << endl;
// File << " : " << line << endl;
// File << " : " << line << endl;
// File << " "<< endl;
// File << "Single Row: " << s << " " << s << " " << s <<" " << s << endl;
// File << " "<< endl;
CString cStr(line.c_str ());
cEdit1.SetWindowText ( cStr + "\n");
cEdit1.SetWindowText ("Randomised: "+ cStr + "\n");
//tmEnd = time(0);
}
CTime time1=CTime::GetCurrentTime ();
CString strtti= time1.Format ("%Y%m%D%H%M%S");
cEdit1.SetWindowText (str);
cEdit1.SetWindowText (strtti+"\n");
//cout << tmEnd-tmStart << " seconds " << endl;
}
</code>
|
|
|
|