|
hi alok,
no not a singleton class, it was an interview question abt the static class, do we have it just like a static member variable and static function,
wat is its significance/purpose?? can i create an object for this static class?? wat happens?
thank u, kk
|
|
|
|
|
The code snipet below demonstrates the variable instance obj to be static not the type Type , even though it would be confusing you.
#include <iostream>
int main()
{
static class Type
{
public:
void Hello() { std::cout << "Type::Hello() \n"; }
} obj;
obj.Hello();
return 0;
} Which is equivelent to:
#include <iostream>
int main()
{
class Type
{
public:
void Hello() { std::cout << "Type::Hello() \n"; }
};
static Type obj;
obj.Hello();
return 0;
}
Maxwell Chen
|
|
|
|
|
i hesitated to show off this example, but finally didn't, thinking it would confuse most beginners around. by the way, it is perfectly legal to do so, as we declare a variable with the type definition inlined...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
And a further example to demonstrate that the member variables are not shared among individual static instances.
#include <iostream>
static class Type
{
int v;
public:
void Hello() {
std::cout << "Type::Hello() \nv = " << v << " \n";
}
void Hello(int n) {
v = n;
std::cout << "Type::Hello(" << v << ") \n";
}
} g_obj, g_objx;
int main()
{
std::cout << "g_obj \n";
g_obj.Hello(3);
g_obj.Hello();
std::cout << "g_objx \n";
g_objx.Hello();
return 0;
} The output goes to:
g_obj
Type::Hello(3)
Type::Hello()
v = 3
g_objx
Type::Hello()
v = 0
Maxwell Chen
|
|
|
|
|
C# has the concept of a static class: a static class is a class that contains only static members and instances can't be created with the new keyword. C++ has no such concept; although you can create classes with only static members you do so explictly and the compiler will not stop you from adding a non-static member.
Steve
|
|
|
|
|
kumar_windows wrote: is there any thing like static class in c++
No.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
I am getting the following error while compiling a project in a workspace.
fatal error LNK1202: "C:\product\GUI\Widgets\SafetyEventLine\Modules\vc60.pdb" is missing debugging information for referencing module
Please let me know:
1] Why does this error occour?
2] How to prevent this error
regards
-- modified at 9:20 Friday 12th May, 2006
|
|
|
|
|
and if you again rebuild project did you get this error?
|
|
|
|
|
Yes....i get this every time I am building my project
|
|
|
|
|
i got this only once many years ago(i dont remember whats happen exactly)
but i know your program has one error
Did your prgoram is run in memory?
-- modified at 9:39 Friday 12th May, 2006
and you close Vs and run again you build program you get this error right?
|
|
|
|
|
yes it repeats every time i try to build the dsp.
|
|
|
|
|
well explain this error is difficult for me i know this error but i cant say that how you solve this error
|
|
|
|
|
I also have got yhis problem but
I solve it:
it can be happen if you have a library and you has changed its location.
When you relocate that library, there is no problem
|
|
|
|
|
Even with a Rebuild All?
Have you tried removing the vc60.pdb file?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Yes....but the result is same
|
|
|
|
|
Do the following things.
1)Delete all the .obj and .pdb(program database (PDB)) files
2)use the compiler's /Zi option
3)Rebuild the application
AppU
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
my project contains following options:
/nologo /MD /W3 /Gm /GR /GX /Zi /Od /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "NDEBUG" /Fp"Modules/SafetyEventLine.pch" /Yu"stdafx.h" /Fo"Modules/" /Fd"Modules/" /FD /Zm300 /c
|
|
|
|
|
i think your error is LNK1201 Did you see msdn
|
|
|
|
|
Hi DavidCrow,
this is very bad when you know error but you cant say
now i have this problem i know error but i cant say that how to solve this error
program is run and then it s in memory and if you delete program and build your program you get this error when you close vs and reopen and then open project and then build you get this error
|
|
|
|
|
have the scroll property checked for both vertical and horizontal scrollbar.
scenario 1:
1) you have Clist box
2) Add few entry to listbox till the vertical scroll bar appears
3) is there any way to find at this point that scrollbar has appeared.
so that i may do some action based on that.
Query :
Any point of time given a LISBOX is it possible to find where VERTICAL SCROLL is visible or available
for thendral
|
|
|
|
|
I think u didn't understand what i said
try this..this will add the string to list box untill the scroll bar comes..
for( int nIdx =0; WS_VSCROLL != (m_ListEx.GetStyle()&WS_VSCROLL);nIdx++)
{
m_ListEx.AddString( _T("hi"));
}
// Vericall scroll bar appeared.
// One item will be exceeding the limit..So delete that one..
m_ListEx.DeleteString( m_ListEx.GetCount() - 1 );
nave
|
|
|
|
|
Well, this is how I would do it:
CRect clRect;
m_ListEx.GetClientRect(clRect);
int visibleCount = clRect.Height() / m_ListEx.GetItemHeight(0);
while (m_ListEx.GetCount() < visibleCount) {
m_ListEx.AddString (_T("Hi"));
}
Ok, it is a bit of a hack, but given the tools you get in CListBox, this is the best I could come up with.
|
|
|
|
|
how can i save the time or the serial no of the hard in text file using C++...
plz help me...
bishoy
|
|
|
|
|
|
I see three separate issues here: 1) time; 2) HDD serial number; 3) file I/O. Which are you having troubles with?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|