|
This is a site for those who write actual code and the code does not work. Figure your own ideas on your own time.
______________________
stuff + cats = awesome
|
|
|
|
|
I am new to C++ have done some mainframe programming
I have a C++ question I figure Here is the best place to post it
What is the main advantage of having base and derevied classes instead of 2 seperate declarations
e.g.
Class MyClass : public CSstring
{
.
.
.
}
As opposed to
Class MYclass;
Class CSstring;
Is it that in former I can get at CSstring protected members/Methods ????
Thankx
|
|
|
|
|
There are many uses of inheritance, one of them being that you can develop interfaces. Inheritance is also a fundamental when it comes to using object-oriented design to solve problems. Depending on what kind of problems you are trying to solve and the complexity of the framework that you have to design, you may not use it much, or you may use it quite extensively.
In your example, yes, you can access protected members/methods, but that's not the reason why you'd use inheritance. If you have no need for any class hierarchy, then there might not be any benefits from using it.
|
|
|
|
|
its mainly a design thing The Base Class could be the lowest level interface, Where a user is Using a Object he/She may not need to access that low a level However the Derived Class may have a need for it
I have a project I want to write and I think once I get to coding I'll get a better feel for it
Thankx
|
|
|
|
|
What if you had a Car class and a Truck class? It wouldn't make much sense to have all of the common aspects duplicated between each. Instead, everything that is common to both a car object and a truck object should go in a base class (named Auto or Vehicle). Make sense? You could apply the same logic to:
Shape
/ | \
Ellipse Rectangle Triangle
| |
Circle Square And:
Animal
/ | \
Dog Cat Horse
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thankx I beginig to get the idea
|
|
|
|
|
Hello board, I want to print 10 columns in a list box so that it seems visually they are ordered in columns.
I use this code:
<br />
--- ------ ------ ------<br />
--- ------ ------ ------<br />
--- ------ ------ ------<br />
sInfo.Format(_T("%5d"), i);<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d1),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d2),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d3),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d4),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d5),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d6),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d7),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d8),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d9),<br />
Now , when I use this code deponding on number of significant digits in the double number, columns shift either to left or right(if number of digits are less than above row the whole row shifts to left and vice versa).
but when I use this code:
<br />
sInfo.Format(_T("%5d"), i);<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d1),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d2),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d3),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d4),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d5),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d6),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d7),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d8),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d9),<br />
everything becomes as I desire. I explain it in this way that size of blank characters that are placed in the first code is less than size of other digits. I actually do not like to see these zeros here(I wouldn't complain if these zeros were at right side of my bank account but not here ).
Is there anyway that blank characters be printed with the same size of other digits? thanks.
|
|
|
|
|
You could use a fixed-pitch font for the listbox:
LOGFONT logFont;
memset(&logFont, 0, sizeof(logFont));
logFont.lfHeight = -10;
logFont.lfWeight = FW_NORMAL;
logFont.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
m_fixedfont.CreateFontIndirect(&logFont);
...
m_ListBox.SetFont(&m_fixedfont, FALSE);
m_ListBox.AddString(_T("0.01 123.12"));
m_ListBox.AddString(_T("0.01 23.12"));
m_ListBox.AddString(_T("0.01 3.12"));
m_ListBox.AddString(_T("0.01 123.12"));
m_ListBox.AddString(_T("0.01 123.12"));
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks alot mark, it definately looks good. problem solved!
|
|
|
|
|
Electronic75 wrote: problem solved!
Why not just use a list control (in report mode)?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi all.
i am trying to output two windows using GLUT and for some reasons, only one window can be rendered at a time. when i try to output two windows, the application just flashes and closes immediately. i comment out on or the other window creating (glutCreateWindow) line, it works by outputting one window..
so my question is if it is possible to create two windows simultaneously and if yes, how??
--
dg
|
|
|
|
|
How can i get my network card's detailed info with WMI and without WMI ?
Thank you very much.
|
|
|
|
|
|
Thank you very much Mark , once again
Regards
|
|
|
|
|
You're welcome!
Did you ever get the Nero QT decoder to work? I couldn't do it on my machine
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I have used cyberlink filter instead of it , and it worked properly
|
|
|
|
|
Cool! Thanks
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
How can i enumerate and get infos of them with WMI and without WMI in user-mode ?
Thank you very much...
|
|
|
|
|
I canot make CArray work in three dimensions.
Here is the code snippet
definitions
typedef CArray<double,double&> CDataArray; //single
typedef CArray<CDataArray, CDataArray&> CDDataArray; // double
typedef CArray<CDDataArray, CDDataArray&> CDDDataArray; // tripple
CDataArray m_D_Data_Array;
CDDataArray m_DD_Data_Array;
CDDDataArray m_DDD_Data_Array;
size initialization
m_D_Data_Array.SetSize(10,10);
m_DD_Data_Array.SetSize(10,10);
m_DDD_Data_Array.SetSize(10,10);
code
int size = m_D_Data_Array.GetSize(); // size = 10
size = m_DD_Data_Array.GetSize(); // size = 10
size = m_DDD_Data_Array.GetSize(); // size = 10 !!!
m_D_Data_Array.SetAtGrow(itemIndex,data); // pass
m_DD_Data_Array[iSample].SetAtGrow(itemIndex,data); // pass
m_DDD_Data_Array[idataType][iSample].SetAtGrow(itemIndex,data); // fails
It fails in assertion
index < m_size
with size = 0, but my m_DDD_Data_Array.GetSize(); returns correct size of 10 elements.
Am I out of luck with using tripple CArray??
I actually need up to six dimensions, so is it time to learn vectors?
Or am I going to run into same problem?
Thanks for reading.
-- modified at 16:23 Saturday 16th June, 2007
|
|
|
|
|
Can you modify your post - check the "Ignore HTML tags in this message" box so we can see all
your code
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I am using VS 2005 on Vista and creating a proress bar. The progress bar in the editor has a glassy, fancy look to it, but during runtime, I end up seeing the regular old flat Progress bar.
Is this just in Vista? It bothers me how I am tricked by that. It is not WYSIWYG.
I am porting a large Borland C++ application to MFC and C# and am trying to make cleaner and fancier UI where possible. Perhaps I may end up using .NET to get the nicer look for this dialog.
|
|
|
|
|
Please give me some idea.
how to write the code for communicate with soundcard
|
|
|
|
|
To do what?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
http://www.zeitnitz.de/Christian/Scope/Scope_en.html
that link implement oscilloscope from soundcard using Labview.
I think it also work in c++.
|
|
|
|
|
So you need to read 16 bit samples at 44.1kHz? I'm not sure what the article's author used but
two ways I know to read data from the soundcard are:
Windows Multimedia Waveform Audio[^]
DirectX - DirectSound[^]
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|