|
I think you will need to revise a little bit your C++ books . x and y are not variables from the class but are parameters you pass to the functionB function (without space, otherwise it won't compile).
So if you want to call the function and pass those parameters, you do like that:
abcOject->functionB(3,4);
But I don't understand really what you try to achieve...
|
|
|
|
|
I tried to recreate the problem below, but it does not generate any errors.
Problem: The original code (way to much to post) generates 'error C2039' in VC6 on testFuncB.
Q1: Has anyone seen this happen before?
Q2: What was the error message, in VC7, that followed this one.
As far as I can tell the original matches the example below:
#define _CLASS_A_ classA<T>
template<class T>
class classA
{
int n_;
public:
void testFuncA(void);
};
template<class T>
void _CLASS_A_::testFuncA(void){ n_ = 0; }
#undef _CLASS_A_
#define _CLASS_B_ classB<T>
template<class T>
class classB
{
public:
typedef T argClass;
T mT_;
void testFuncB(void);
};
template<class T>
void classB<T>::testFuncB(){ mT_.testFuncA(); }
#undef _CLASS_B_
typedef classA<char> classA_type;
typedef classB<classA_type> classB_type;
int main(int argc, char* argv[])
{
classB_type B;
B.testFuncB();
return 0;
}
I know, not enough information. Could you please take a stab in the dark anyway, any possible cause will be welcomed.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
John R. Shaw wrote:
Q2: What was the error message, in VC7, that followed this one.
Q3: What did you mean in Q2?
Just to make this post somewhat useful, the global typedefs before the main function should be read as follows:
typedef classA<char> classA_type;
typedef classB<classA_type> classB_type;
I kept wondering what purpose served those typedefs until I looked at the HTML source You may want to edit the original post.
As to why that would generate a C2039, I'm so in the dark I don't even dare to try a stab. Sorry
Hmm... actually, I'll try one. While coding with templates, I sometimes get to see puzzling compiler errors in situations like this:
typedef classB<classA<char>> classB_type;
The problem with the above code, which is isn't evident at all from the error messages it generates, is that the compiler gets confused by the two consecutive closing angle brackets and takes them for the >> operator. If you insert at least one space between them, the errors do go away:
typedef classB<classA<char> > classB_type;
Any chance your original code suffered of this problem?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose Lamas Rios wrote:
Q3: What did you mean in Q2?
:-DAhhh! I asked a question a couple of days ago as to why the VC6 compiler complaned about externaly defined functions of a templated class that was defined internaly to the template class. VC7 generated an additional error that stated that the feature was not supported (a better error message). I would have assumed that VC7 would be fully compliant with the C++ standard, but apparently is is not.
Thanks for the stab, even thou it did not work. I've had to do things like that in the passed, but if you need to do that then there is some thing wrong with the compiler (and you need to note why you did it, the compiler and compiler version).
P.S. Very good, most people would not think of looking at the HTML code (to much trouble). I thought I had coverted it completely, oviously I was wrong. I have modified it so that it now makes since.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
|
Nope. But thanks for the stab!
I am going to start undoing the last changes I made, before this error started happening.
Blast It, thats alot of work, but I'll find it.;)
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hello Everyone,
I have been trying to add methods through ClassWizard but Its saying that "Error while updating *****.h and *****.cpp file". The methods I am trying to add are like Onselchange(), Button Clicks like OnButton4() etc. I am unable to add any. I did try following measures to solve this issue but none helped:
1. Deleted .clw and .ncb files, then added all source files to create fresh ClassWizard.
2. Looked if any file is Read-only (but none was Read-Only).
3. I tried to manually add these methods by writing AFX handlers in header file and then implementation in CPP file. But that is also not working.
Please help me about what could be wrong, what can I do to get things right ?
Thanks in Advance....................
Regards,
-- Prateek
|
|
|
|
|
I do not know what causes the problem, but it happen to me about 20 minutes ago (and many times in the past, in VC6).
Note: This solution assumes the class did not exist before exicuting the ClassWizard.
My solution:
1. Yes the ClassWizard complaned, but it still generated the file. So delete the ClassWizard generated class file from the workspace.
2. Close IDE.
3. Delete generated file.
4. Open IDE and run ClassWizard again.
Closing the IDE is important, since it is in a slightly unstable state; if it wasn't, it would have been able to update the file it just generated.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi,
I think it has something to do with Default Read-Only setting of Windows XP Professional folders. What do you think ?
Regards
--Prateek
|
|
|
|
|
What do I think?
I think you're wrong (but, I could be wrong).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hey everyone,
I need a map class to represent the data in a sort of network class I'm making and I've been looking at Boost graph library for this. The one feature I really need is the ability to join two graphs together, by specifying a vetex from each that should be joined with an edge. Although Boost::mutable_graph looks close to what I want, I don't see how I can implement my join/union/addition operation in an efficient manner with the boost graph operations. Does anyone have experience with this problem and know of any potential solutions for it? Any suggestions for libraries that might work? I am going to check out the Graph Template Library and see if that might support this better. I could always make a graph structure that is optimized for my operation, but that would probably take more time than just finding something preexisting that just works.
Any suggestions?
|
|
|
|
|
A rough guess:
map1[0,1] = ?
map1[0,2] = ?
...
map2[0,1] = ?
map2[0,2] = ?
...
join(map1,map2);
new_map1[0,1] = ?
new_map1[0,2] = ?
...
Possible Solution:
void shift_keys(map_type& map, map_type::size_type amt)
{
map_type new_map(map);
map_type::iterator mi = map.begin();
for( ; mi != map.end(); ++mi )
new_map[std:make_pair((mi->first).first+amt,(mi->first).second+amt)]
= mi->second;
map.swap(new_map);
}
vod join(map_type& map1,map_type& map2)
{
map_type new_map(map2)
shift_keys(map2,map1.size());
map_type::iterator mi = new_map.begin();
for( ; mi != new_map.end(); ++mi )
map1[mi->first] = mi->second;
}
This is an incomplete solution (off the top of my head). It should successfully join the two maps.
Example:
join(map1,map2);
map1[0,1] = ?
map1[0,2] = ?
..
map1[2,3] = ?
map1[2,4] = ?
...
I hope that helps you figure out the problem. Maps allow only one entry per-key; therefore, you have to change any key values in map2 that may be the same as a key values in map1 before you attempt to join them.
It may be more complicated than that, but I have essentially used simular code to join two maps.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I want to create command buttons dynamically in an dialog based application - is this possible?
Ger
|
|
|
|
|
Ger Hayden wrote:
is this possible?
Yes, Just make sure the ID's you assign the buttons are within a certain range and use the ON_CONTROL_RANGE macro to map your buttons to a handler function.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_Handlers_for_Message.2d.Map_Ranges.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I have a button in an application. The user has to click that
button first to pop up a dialog box and get started. So I have
the text on the button that says 'Click here first'. But people
dont see the button.
So I made the button a hover button, so that it looks hot when
you hover over. But people still miss the magic button.
My question is, is there a way to make a button blink alittle
(not alot so that its annoying)? Just a light blink on occasion
to catch the user's eye.
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Start a timer (see CWnd::SetTimer ) with handler value of NULL and create a message handler for WM_TIMER, you can do the colour control etc. there.
Elaine
The tigress is here
|
|
|
|
|
using SetTimer() is the right manner to set a blinking effect.
but can i suggest you to disable the other buttons if only this one should be clicked ???
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Rule #1 of UI: Users don't read.
If the only way to start is to click the button, why do you make the user click it? Just start whatever it is the app does.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
What is wrong with this?, how can I use this to make it work?
CString sDriveLetter= (TCHAR) (i + ('A'));
This is the error I get;
cannot convert from 'TCHAR' to 'ATL::CStringT<basetype,stringtraits>'
|
|
|
|
|
What is the error number (C####) that the compiler gave you? If you look up that error number in MSDN you can usually figure out what the problem is by reading the explanation provided.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
CString sDriveLetter;
sDriveLetter.Format("%c", (TCHAR) (i + ('A')));
Tom Archer
Visual C++ MVP
|
|
|
|
|
Unless MFC CString class varies from STL, that would be Illegal.
CString sDraveLetter = _T('A');
CString sDraveLetter = _T("A");
CString sDraveLetter;
sDraveLetter = TCHAR(i+_T('A'));
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I am having a little problem handling Threads. Problem is, there is a Thread that i want to Terminate when Destructor of a Class called. Thread function is Using some functions of that class. I have done bit reading on Threading(still learning concepts etc) and about terminating a thread the way i want to use is AfxEndThread. it must be called within the thread that has to be terminated. or can it be called outside that thread also. or is there any way to terminate that thread from outside by some other thread.
<br />
pThread = AfxBeginThread(run,&nCount,THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);<br />
pThread->m_bAutoDelete=false;<br />
pThread->ResumeThread();
thats how i am initializing the Thread. Now what if i just delete pThread object will this terminate the thread.
**************************
bit more detail...
above code is placed in the constructor of same class .. now another class when makes object of this class thread should start working and when it delets the object thread must also be end. I am getting some assertion error while some where in terminating the thread. and don't know where
|
|
|
|
|
well the Error I am getting is
Debug Assertion Failed.
File: WinCore.cpp
Line: 1002
well is this problem of my thread. :s
|
|
|
|
|
Hallo, I had a simmilar problem and I solved the problem by using a shared bool var. if the var is set to true from outside the thread terminats its self. Try to use it.
Meinhard
|
|
|
|