|
hello ,everybody!
i like thiking! give some think with a software or web site.for example : you can tell me which sort with soft or web site! thanks!
|
|
|
|
|
Im sorry but I dont understand what you said?
|
|
|
|
|
i want to you tell me some idea about software. for example :which sort(idiographic function) about a soft !
because i want to developed the software . Have you any good idea?
|
|
|
|
|
A good choice for a first program is to write a calculator.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
lgbean wrote: ...i want to developed the software . Have you any good idea?
Yes. Start with a spell/grammar checker. You'll get instant gratification from it.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello everyone,
I met with a strange issue that derived class function can not access base class's protected member. Do you know why?
Here is the error message and code.
<br />
error C2248: 'base::~base' : cannot access protected member declared in class 'base'<br />
<br />
class base<br />
{<br />
protected:<br />
~base() {}<br />
private:<br />
void foo()<br />
{<br />
base* b = new base;<br />
delete b;<br />
}<br />
};<br />
<br />
class derived : public base<br />
{<br />
public:<br />
~derived() {}<br />
private:<br />
void goo()<br />
{<br />
base* b = new derived;<br />
delete b;
}<br />
};<br />
thanks in advance,
George
|
|
|
|
|
The base destructor is protected.
I guess it seems logical that if derived derives from base then it
should have access to the protected destructor but it doesn't work
that way.
You can fix it by making the base destructor public, making
derived a friend of base, etc.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark,
Do you think destructor has something special or there is something wrong with my code? I think derived class should be able to access protected member of base class, right?
regards,
George
|
|
|
|
|
Which compiler are you using ? If it is VC6, then it is a known bug of the compiler itself. If you compile this code under VC2003 or VC2005 this should just work.
|
|
|
|
|
Hi Cedric,
I am using Visual Studio 2005. I do not think there is a bug, and I think there should be something wrong with my code. How do you think of it?
regards,
George
|
|
|
|
|
It doesn't work on 2005 or 2008 either.
I'm going to ask MS about this. I honestly don't know why it
doesn't compile. Intuition talls me it should work but it's probably
one of the many things I don't know about C++
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok, thanks to a Fellow MVP, I got some answers.
It's not a VC bug.
The behavior is also the same on VC 2008 (I tested that).
void goo()
{
base* b = new derived;
delete b; // error in this line C2248: 'base::~base' : cannot access protected member declared in class 'base'
}
The problem is, even though you're in a class publicly derived from base, the
compiler only knows it's dealing with a base object ("b") so you don't
have access to any private or protected members of b. Only when the object is
of type derived does the compiler know that the base class protected members are
accessible from derived.
If, in the above code, b was a "derived" object, you'd have no problem.
To fix it, you can:
a) Make the base destructor public.
b) Make derived a friend of base.
c) In Goo(), create a derived object instead of a base object.
Each method has pros and cons, depending on what you need for your implementation.
I'm not sure why you have the base destructor protected. If you are trying to prevent
base objects from being created, then you should probably have a protected (or private)
default constructor as well, so creating a base object will fail to compile as well.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark!
Your reply is so comprehensive and great! I have tried and it works.
regards,
George
|
|
|
|
|
I created a simple windows socket program, it acts as a client only that sends data to specific server application. When I tried to send the message, I noticed in the receiving application that the series of data is accumulated altogether in one message only. I intended to send the data to be one by one.
Please help, thanks a lot.
Jers
|
|
|
|
|
If you are using synchronous sockets (so, using send and recv functions), there is no notion of packets there. You just read a certain amount of bytes. If you want to keep packets, you will need to send first the size of the packet. On the other side, you simply read this data (coded on 1,2 or 4 bytes depending on your needs) and then read the corresponding number of bytes.
|
|
|
|
|
|
Hi
In a dialog I have 3 edit boxes, and a button,
After Clicking on this button I want to know that: which edit box had focus?
Is there any way?
Thanks
|
|
|
|
|
when you click button then button has focus,can you use of GetFocus ?
|
|
|
|
|
When you click the button the button will receive a WM_SETFOCUS message.
That message contains the handle of the window that lost focus. You could compare
that handle to the edit control window handles.
An alternative is to have the edit controls track when they get focus.
Remember that the last window with focus when your button is clicked isn't necessarily
going to be one of the edit controls. It may not even be a window in your app.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all. Im trying to make the same function but with a console instead of a Window app. The code is from this site here: http://www.codeproject.com/system/Hack_Windows_Task_Manager.asp
From what i can see in my version i've done everything right but its not doing the desired task which is to wipe the list in task manager.
Here's what i have.
<br />
#include <iostream><br />
#include <afxcmn.h><br />
using namespace std;<br />
<br />
BOOL CALLBACK EnumChildProcedure(HWND hWnd, LPARAM lParam);<br />
<br />
void main(){<br />
HWND taskmnger = ::FindWindow(NULL,"Windows Task Manager");<br />
if(taskmnger){<br />
cout << "Task Manager window found! " << endl;<br />
EnumChildWindows(taskmnger,EnumChildProcedure,NULL);<br />
}<br />
else{<br />
cout << "Not found! " << endl;<br />
}<br />
}<br />
<br />
BOOL CALLBACK EnumChildProcedure(HWND hWnd,LPARAM lParam)<br />
{<br />
char name[256]; <br />
GetWindowText(hWnd,name,256);<br />
<br />
char ClassName[256];<br />
GetClassName(hWnd,ClassName,256);<br />
<br />
if((strcmp(ClassName,"SysListView32")==0)&&(strcmp(name,"Processes")==0))<br />
{<br />
cout << "Process tab Found! " << endl;<br />
}<br />
if((strcmp(ClassName,"SysListView32")==0)&&(strcmp(name,"Tasks")==0))<br />
{<br />
cout << "Task tab Found! " << endl;<br />
}<br />
if(name==NULL)<br />
return FALSE;<br />
return TRUE;<br />
}<br />
Im thinking my problem lies in the SendMessage function. Everything else seems to work. EnumChildWindows() and the Enum function all detect the lower windows. But when it finds the windows, it doesnt pretty much do anything. So if anyone has any suggestion as to what im missing please let me know. Thanx in advance!
|
|
|
|
|
hi every one
am stuck, this is what i want to do.
i have a Report styled list control with 5 columns and i have a double clicked event handler for the list control; so i want to get the index of a row once i double click on it, which list control function do i interrogate, e.g
if it was a list box , i would do this;
CListBox m_Listbx;
....
...
int nSel = m_ListBox.GetCurSel();
now in CListCtrl what function is analogous to CListBox's GetCurSel() and how is it used..
thanks;
|
|
|
|
|
GetNextItem(-1,LVNI_SELECTED); .
|
|
|
|
|
GetNextItem()
retrun value is an integer.the integer is your need
|
|
|
|
|
About several weeks I tried to learn MFC,but unfortunately failed to do so.
At first I was confident ,but then I got frustrated 、confused and didn't know what to do.
I think I've known C++ well,and know something about computer organization and operating
system .But I just could copy the same codes as described in the books,even cannot change a bit.
I didn't know exactly what the code means,and could nou find the ways.Is it googbye to the MFC world? I wonder....
Hope for help.
|
|
|
|
|
If you can not write your code so you are faint on MFC and need to more work of course codeproject has articles about MFC and its controls but I suggest see codes that has beginner on their titles, do you know c++ very well for example Object Oriented Programming (inheritance,Polymorphism) and Type Casting,Preprocessor directives, Input/Output,Arrays,Pointers Dynamic Memory and other things,but I didnt understand you cant change codes on books?
|
|
|
|