|
Thanks friends TClarke,toxcct and Mila025 for your guide .
|
|
|
|
|
The following won't compile with the following error :
error C2660: 'B::f()' : function does not take 2 arguments
class A{<br />
public:<br />
virtual void f(int a, int b); <br />
};<br />
<br />
class B : public A{<br />
virtual void f(int a)<br />
{<br />
f(a, 1);<br />
}<br />
};
I fail to see the logic error !!! can anyway shed some light ?
Odesh
|
|
|
|
|
-- forget, nothing interresting here --
|
|
|
|
|
toxcct wrote: the function A::f() inherited mush be implemented
Again, this is false. This statement is true only if the function is pure virtual. You can perfectly have a virtual function in the base class which is not implemented in one or several derived classes (even not implemented at all in the derived classes).
|
|
|
|
|
odesh wrote: error C2660: 'B::f()' : function does not take 2 arguments
I think you should try this:
class B : public A
{
virtual void f(int a)
{
A::f(a, 1);
}
};
I hope this helps.
|
|
|
|
|
won't compile more. A::f() is virtual, so, not implemented...
moreover, the compilation error is no B::f() implementation overloads A::f()
|
|
|
|
|
toxcct wrote: A::f() is virtual, so, not implemented...
You can perfectly have a virtual function that is implemented in the base class. Making it virtual doesn't mean that you cannot implement it. I think you mix it with a pure virtual function which is:
virtual void f() = 0;
|
|
|
|
|
Cedric Moonen wrote: You can perfectly have a virtual function that is implemented in the base class
yes, i know that, but it didn't seem to be here...
|
|
|
|
|
The proposed solution solves the compilation error message mentioned in the original post: "error C2660: 'B::f()' : function does not take 2 arguments". In my opinion, just adding an implementation for A::f() is not a solution for original problem. Missing implementation (if really was not done by the author) will be reported on linking phase.
|
|
|
|
|
The problem is that function overloading is limited at the class scope, that means you cannot overload a function in a derived class (or you need to implement the function which is overloaded too).
|
|
|
|
|
Thanks for the help Cedric,
of course the problem i was refering to had nothing to do with implementation, i just got lazy (which doesn't make a better developer out of me i guess).
|
|
|
|
|
|
thanks so much for the link, it helped alot!
|
|
|
|
|
odesh wrote: can anyway shed some light ?
Class B needs a using statement.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello friends,
I have one question n my question is... How i can read data from .txt file.I have one drawing in autocad which contain all loop name as a text.If i will click on any looptext name then it will open that page..
I have file.. name is "WG_LL.txt" file at particular location.Following data are containing inside my file.
L 10011LoopO\00000001\00000001\00000001.xml
L 400142LoopO\00000001\00000008\00000042.xml
NP10033LoopO\00000001\00000001\00000003.xml
T 10022LoopO\00000001\00000001\00000002.xml
If i will click L 1001 from the Autocad drawing then it will open
" L 10011LoopO\00000001\00000001\00000001.xml" file..I know we can use "shellexecute" to open the document but i dont know how to read data.
Plz any body know then help me bcz i am new in this field..
Thanking u very much.
shah
|
|
|
|
|
Here a code snippet that might help you:
<code>
HANDLE hFile;
DWORD dwNumRead;
BOOL bTest;
char dwBuffer[256];
hFile = CreateFile("File1.txt", GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
bTest= ReadFile(hFile, dwBuffer, sizeof(char)*256, &dwNumRead,NULL);
char seps[] = "\n\r";
char *token;
char *Lines[10];
for (int i=0;i<10;i++)
{
Lines[i] = NULL;
}
token = strtok( dwBuffer, seps );
int x = 0;
while( token != NULL )
{
Lines[x] = token;
token = strtok( NULL, seps );
x++;
}
</code>
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
« Programm3r » wrote: The only programmers that are better than C programmers
*grin* It's possible he's using C, in which case your sample is very useful. If he's using C++, I'd strongly advise against using C file handling.
Christian Graus - C++ MVP
|
|
|
|
|
Christian, don't care, it's his sig
|
|
|
|
|
I *know* it's his sig, but the code he posted is also C, and I would strongly advise against using it in a C++ program.
Christian Graus - C++ MVP
|
|
|
|
|
|
Hi Christian,
The whole " ... The only programmers that are better than C ..." is just my signature But you are right I would strongly advise against it too.
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
« Programm3r » wrote: The whole " ... The only programmers that are better than C ..." is just my signature
So why not set it apart from the rest of your post (so that folks don't take it out of context)?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
The standard C++ way is to use an ifstream. This has the advantage of providing a clean way to read the data, especially if you know exactly what format it's in.
I recommend googling for ifstream for some examples.
Christian Graus - C++ MVP
|
|
|
|
|
Shah Satish wrote: How i can read data from .txt file.
If you are using MFC, check out the CStdioFile class. If not, check out the STL's ifstream class.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|