|
Isn't GCC only for UNIX? Or is there some way of getting it run well with windows? Does it work with XP?
With time we live, with money we spend!
Joel Holdsworth.
|
|
|
|
|
|
hi
I'm new to C++ and would like to know how to load a file into a buffer. Is it something like
char *buf1 = fopen(??);
though that does not seem to work
thanks
|
|
|
|
|
FILE * pf;
pf = fopen("C:\\File\\Path\\File.extension" , "R" );
if (pf) { // File well opened
// in order to read work on the fread function
}
if u want to use MFC see the CStdioFile or CFile class
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
tx for the reply.
pf (file in my case) unfortunately does change, but to 0, so the if function isn't entered. The file does exist, cuase I'm using the following code:
FILE *file;
CFileDialog cf(TRUE);
//Get Filename
if (cf.DoModal() == IDOK)
{
CString m_pathname1 = cf.GetPathName();
file=fopen(m_pathname1,"R");
}
if (file)
{
//does not enter here!!
}
what am I doing wrong?
|
|
|
|
|
tx for the reply
pf (file in my case) unfortunately does change, but to 0, so the if function isn't entered. The file does exist, cuase I'm using the following code:
FILE *file;
CFileDialog cf(TRUE);
//Get Filename
if (cf.DoModal() == IDOK)
{
CString m_pathname1 = cf.GetPathName();
file=fopen(m_pathname1,"R");
}
if (file)
{
//does not enter here!!
}
what am I doing wrong?
|
|
|
|
|
file=fopen(m_pathname1,"r");
with a lowercase 'r'
"640K ought to be enough for anybody."
Bill Gates
|
|
|
|
|
I like to right align tree control. If you know any idea then please tell me. Actually i want to print tree items in Arabic and for this purpose i needed to change the alignment of tree control items. If you know any such sample application or method then please tell me.
|
|
|
|
|
|
Hi,
I want to access member functions of my derived CPropertyPage
Classes from the PropertySheet in a for loop. The problem is that I don't how to get a pointer to the correct PropertyPage Class
I can do it like this
<br />
CParameterList parList;<br />
CMainPage* mainPage = GetPage(0);<br />
parList = mainPage->GetList();<br />
DoStuff();<br />
<br />
CDrivePage* drivePage = GetPage(1);<br />
parList = drivePage->GetList();<br />
DoStuff();<br />
<br />
and more<br />
But it would make more sence if I could do it in a loop
<br />
for (int i = 0 ; i < GetPageCount(); i++)<br />
{<br />
CParameterList parList;<br />
CPropertyPage* page = GetPage(i);
parList = page->GetList();
DoStuff();<br />
}<br />
van Padoea
|
|
|
|
|
1) You can use IsKindOf:
CPropertyPage* page = GetPage(i); <br />
if(page.IsKindOf(RUNTIME_CLASS(CMainPage))) ((CMainPage*)page)->GetList();
2) If you have GetList() methods in all your pages, you can derive your pages from a intermediate class which defines the GetList() method as virtual:
class CListPage:CPropertyPage<br />
{<br />
virtual CParameterList GetList()=0;<br />
...<br />
}<br />
<br />
class CMainPage:CListPage<br />
{<br />
virtual CParameterList GetList(){...}<br />
...<br />
}
Sonork 100.15206;PavelK
|
|
|
|
|
Thank you,
Will try option 2 first.
van Padoea.
If every fool wore a crown, we would all be king - Lard
|
|
|
|
|
Hi, everyone!
Take a look at the following source codes,
--------
#ifdef __cplusplus
extern "C" {
#endif
--------
In my experience, we can use function and variable after
the key word "extern", but what means "C" {
here?
Cheers,
George
|
|
|
|
|
This means that all following exported functions are in C style (and not C++, even if you are coding in C++).
If you declare something as C, you cannot use polymorphy (two functions with same name but different parameters). Every function has a unique name.
Using this declaration, you can use the DLL in Visual Basic or Pascal for example.
Dominik
|
|
|
|
|
Dominik Reichl wrote:
If you declare something as C, you cannot use polymorphy (two functions with same name but different parameters).
Actually, this C++ feature is called 'overloading', not 'polymorphism'
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Tomasz Sowinski wrote:
Actually, this C++ feature is called 'overloading', not 'polymorphism'
Yeah, but very curiously I have heard quite a few people refer to overloading as a kind of static polymorphism whereas the actual polymorphism is referred to as dynamic polymorphism. I thought it was some kinda Trivandrum thing Anyway since I wasn't sure I decided not to correct them
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nishant S wrote:
I have heard quite a few people refer to overloading as a kind of static polymorphism
Strange - I don't know where they get this. Can you ask them for reference?
I believe there's a distinction between compile-time polymorphism (templates) and run-time polymorphism (inheritance/virtual functions).
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Alexandrescu says something of the sort somewhere in his book "Modern C++ Desisgn", if my memory serves me well.
If you think it over, the mechanism by which one or other overload of a given function is selected mimics polymorhpism in which it is the type of the objects involved that drives the selection of the right implementation:
class A{...};
class B:public A{...};
void f(A& a);
A a;
B b;
f(a);
f(b); If now we define an additional overload things change:
class A{...};
class B:public A{...};
void f(A& a);
void f(B& b);
A a;
B b;
f(a);
f(b); IMHO this is a very close compile-time equivalent to virtualness.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
PS: Anyway, I totally agree with you polymorphism is commonly used to refer to the run-time kind.
|
|
|
|
|
You're right. Alexandrescu, "Modern C++ Design", page 264
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
|
Thanks, Dominik pal!
Your reply has resolved all my doubts!
Cheers,
George
|
|
|
|
|
This is used in header files that must be compatible with both C and C++. extern "C" tells the C++ compiler that anything inside the curly braces { } must be treated as C language declarations.
|
|
|
|
|
Thanks, markkuk, my old friend!
Your reply has resolved all my doubts!
Cheers,
George
|
|
|
|
|
I want to install hook to detect Win32 function called, eg. ::TextOut(). What type of hook I should use?
|
|
|
|
|