|
After writing and erasing two lengthy replies (covering the history and philosophy of OO design) i see the merit in your reply. You are very wise.
Although, i personally would have said 42 lines ... 42 being THE answer and all.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
ROTFL - brilliant. I can't wait to hear the new HHGTTG episodes.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I've been given this fantasitc new 13mm wrench.
I know how to use it, but have only done so with 13mm nuts.
How do i use it to build a car ?
I don't mean to be flipant, but the question begs a reply that covers the whole of the object oriented design paradigm. A topic too large to fit in a reply.
Start by reading up on object oriented design.
Follow up by taking some small procedural programs you may have written and see if you can port some of the code into classes.
The trick is to start seeing your program designs as the interaction of objects, as opposed to the paths of code execution. Wherever you see an 'object', you have a class waiting to be born.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
When to use Classess? What type of classes do u want to use.
Ok whenever u want to do some socket programming then u have to derive it from socket class.
Everything is depend on the situation. Thats is a other matter that u want to go for classes or not. But OO provides the class concept which is one of the beautiful thing.
Neelesh Jain.
Work Hard and A Bit of LUCK is KEY to SUCCESS.
|
|
|
|
|
You use classes to "group" logical pieces of code together.
example:
You have a class car. This class has several properties like maximum speed, color, type, ... and this car can do stuff like drive, turn right and (hopefully) left, brake, ...
now typically your properties are your variables; so you would have a string type, double maxspeed, string color, ...
The things your class can do are your functions. so void Drive(){ ... }, void TurnLeft(){...} and so on.
So far your with me I hope.
Now if you've encapsulated your class you can call this class somewhere else. So you make another class like racetrack in this class you can call as many instances of your carclass as you like. each instance with his own properties...
so in ractrack you declare:
Car Porsche = new Car();
Car Volvo = new Car();
....
now you can set properties:
Porsche.MaxSpeed = 320; // km/h
Volvo.MaxSpeed = 160; // km/h
(note: you have to know you public/private/protected...)
this is just a simple example, but I hope I've made it a bit more clear for you.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
how to draw a line on my class derived from CMSChart?I have handle the WM_PAINT,but I find my OnPaint function is not called ,my codes as follow:
BEGIN_MESSAGE_MAP(CMyChart, CMSChart)
//{{AFX_MSG_MAP(CScreenCap)
ON_WM_PAINT()
//}}AFX_MSG_MAP
// Generated message map functions
//{{AFX_MSG(CMyChart)
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
void CMyChart::OnPaint()
{
if(DRAWLABEL == m_ShowType)
{
DrawBackGround();
DrawLabel();
}
CMSChart::OnPaint();
}
|
|
|
|
|
static DWORD UpdateTimer = timeGetTime();
// Limit all frame updates to 30 fps
if(timeGetTime() < UpdateTimer + 33)
return TRUE;
UpdateTimer = timeGetTime();
this is in my frame() function, it doesn't seem to work.
|
|
|
|
|
Hi, I am looking to access a website and parse some data from it using VC++, I tried looking in MSDN for an API or COM object that I could use but I could not find one, can someone tell me what I should use to accomplish this task?
|
|
|
|
|
|
Thanks bhai.
|
|
|
|
|
Hian Brother,
mr. Ravi Project is COOL
but there one more project on CP that can help you, search for "AmhttpSocket", it is samll class that encapsulate what you want.
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello,
I am having trouble in compiling this project of mine. I will try to make myself clear so please bear with me for awhile...
The scenario
The workspace consists of 4 projects, 3 of them generating static libraries:
- core.lib;
- controls.lib ==> dependant on core.lib;
- db.lib ==> also dependant on core.lib;
The fourth project is the application which uses classes/objects from the 3 libraries I've just described.
The problem
I have just added a new class (CXList ) to core.lib. This class allows the processing of a complex linked-list with variable data types - it is therefore a class template. Before including it in core.lib I tested it in a separate project and it performed just fine.
But, when I included it in the master workspace described above and after having updated the whole project, I couldn't believe my eyes when I hit the Build button! I got loads of linking errors telling me that all (yes all) of the CXList objects (and methods) were not found in any of the libs (you know, the external object not found in db.lib kind of error).
Is this some kind of a class template issue that I am not aware of?
If you think you can shed some light on what I'm experiencing here, please do let me know.
Thank you for your time,
David Nimrod
|
|
|
|
|
By class template i assume you mean CXList is defined like :
template<class TT> class CXList { ... };
If not then i don't know what you mean so stop reading.
Ok, what you have defined with a template is an idea. There is NO CODE until you create a instance of the template by specifying the template parameters.
e.g.
CXList<int> blah;
So even though the template code is included in code.lib project file no object code is produced when you compile.
If you have specific instances of CXList that you want to export from core.lib then you can do the following :
In a header file add :
typedef CXList<int> CXListInt; // optional
In a source file add :
template class __declspec(dllexport) CXList<int>; // required
This will create all the instance code for CXList<int> and export all the methods.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
cmk wrote:
In a source file add :
template class __declspec(dllexport) CXList; // required
That's precisely what I mean.
cmk wrote:
By class template i assume you mean CXList is defined like :
template<class tt=""> class CXList { ... };
Ahh! The magic code to make it work!
I thought the compiler did this automatically. Can you provide me with an explanation as to why you have to do it like so?
Thanks a lot, cmk. You have been very helpful indeed!
David Nimrod
|
|
|
|
|
Whoops, i made a typo
template class __declspec(dllexport) CXList;
should be,
template class __declspec(dllexport) CXList<int>;
dNimrod#X wrote:
Can you provide me with an explanation as to why you have to do it like so?
Because a template is just that - a template that the compiler can use to create code at compile time when you specialize the template.
When you define the template class template<class TT> MyClassT { ... };
The TT is a variable/placeholder. What do you expect the compiler to do with TT unless you specify what it is ?
But, when you say MyClass<int> the compiler goes 'ahhh, now i can replace all cases of TT with int and compile'.
As for exporting, given the above you can't export a template class like you would a normal class. So the syntax i provided was the solution 'they' decided on.
It tells the compiler that, even if CXList<int> isn't used anywhere, you want it to create all methods and export them. If you didn't do this the compiler would optimize away the code.
The same syntax can be used to export function template instances, or specific class template method instances (ie you don't want to export all methods from a class template).
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I have a function within which I launch off a process using createprocess. This function has the signature:
int runMyCAD(char* alg_str, char* output_dir, char* file_path, char* list_file_name, char* serverAddress);
The process I am launching needs to be passed the arguments that came in, so I am trying to build the lpCommandLine for the CreateProcess.
CString CommandLine = "CadcacControl.exe -s ";
CommandLine += *serverAddress;
CommandLine += "- p ";
CommandLine += *file_path;
CommandLine += " - d ";
CommandLine += *output_dir;
CommandLine += " - a ";
CommandLine += *alg_str;
CommandLine += " - l ";
CommandLine += *list_file_name;
CreateProcess( appDir + "fileserver.exe", (LPCTSTR)CommandLine,
NULL,NULL,FALSE,0,NULL,
NULL,&StartupInfo,&ProcessInfo)
but I get the compile error:
feedfile.cpp(275) : error C2664: 'CreateProcessA' : cannot convert parameter 2 from 'const char *' to 'char *'
What do I need to do to fix this?
Thanks,
sb
|
|
|
|
|
This question is asked about a thousand times a day
See the C++ forum FAQ
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I am looking for code for a list control (like CListCtrl) that displays an edit box and button for a current item or sub-item. Microsoft has implemented this in, among other things, the Options/Projects/VC++ Directories dialog where you can type in a directory or click the button for the Open File dialog.
I'm sure it's relatively easy to implement but I even more sure that someone must have already done this and I don't want to re-invent the wheel.
Does any one know of an implementation of this? Any help is greatly appreciated.
|
|
|
|
|
Hello guys,
someone can give me an example on how to use the SetSecurityInfo for a process.
The aim is to set the SecurityInfo for my process in a way that an external process has only the permission to execute it, and deny the operations like ReadProcessMemory, WriteProcessMemory, or OpenProcess with PROCESS_VM_READ, PROCESS_VM_WRITE options...
I really appreciate your help,
Fabio
|
|
|
|
|
Is anyone know know how to write c/c++ code to print out a .jpg image with the given filename directly on a printer without displaying the image itself and without print dialogue popup, but still able to set up the needed parameters?
Many thanks,
David
|
|
|
|
|
decompress it, load it to a memory device context and send it to the printer. where is the problem?
Don't try it, just do it!
|
|
|
|
|
Hello everyone, I need help with an ODBC Api called SQLRowCount().
This Api can only be used to get the number of "affected" rows after an UPDATE, DELETE or INSERT statement. But what if I want the returned rows of a SELECT statement?
(SQLRowCount() is returning -1 then)
I've already browsed the ODBC help files but I didn't find any similar Api.
Any suggestions?
Regards,
Alex
Don't try it, just do it!
|
|
|
|
|
If your query was something like SELECT name,address,phone FROM table WHERE name LIKE 'TER*' then you can simply change it to SELECT COUNT(*) FROM table WHERE name LIKE 'TER*' to get the number of rows returned. Is that anywhere near what you are after?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Perhaps a solution, but not really the one I was looking for. I'm also a PHP coder, and I'm used to work with MySQL, which has an Api called mysql_num_rows, which also returns the SELECT row count. There is a function for ODBC, too, called odbc_num_rows, but this one does only work with some ODBC drivers (the Microsft Access Driver for example doesn't support this, -1 will be returned).
I am currently working on a simple COM server to make ODBC access easier, and for that reason a function like SQLRowCount, working for SELECT requests, would be very useful, because changing the SQL request by using string operations will make the code much slower, more difficult to code and there may also be much more errors.
Any other solutions?
Don't try it, just do it!
|
|
|
|
|
As far as i know there is no reliable way to do this across all drivers.
As i understand things (YMMV) :
When you call SQLExecute*() many drivers will return before the complete result set is built - that is they work async. This is not the same as using SQLSetStmtAttr(SQL_ATTR_ASYNC_ENABLE). This is more likely for static forward-only cursors.
The idea is that they can keep chugging away at building the result set as you pull results out of the set via SQLFetch*().
The upshot is that the total number of rows may not be known at the time SQLExecute*() returns.
There are ways to force the issue, but they all introduce significant overhead.
...cmk
Save the whales - collect the whole set
|
|
|
|