473,586 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fundamental question about visibility

My question is fundamental I beleive but it has been teasing me for a while:

I have two classes in my app. The first class is instantiated as a member of
my second class. Within this first class, a method (event) needs to be able
to invoke methods of the second class. With static classes its possible but
this is not desirable. There's obviouly some visibility problem I am not
familiar with. It is not a parent-child relationship since there's no
enheritance is it? (If so, something like GetParent().Wan tToBeCalled() would
be the right way I guess...)
class FirstClass{
public:
void TriggeringEvent (); // When this is called, invoke
WantToBeCalled of CS
};

class SecondClass{
public:
FirstClass FS;
void WantToBeCalled( ); //
};

SecondClass CS;
....

What fundamental "visibility issue" haven't I understood correct? I've
looked at "export" directives and also suspect namespaces could have
something to do with it but I am getting tired or trial-and-error without
success.

Thanks in Advance,
Casper
Jul 19 '05
51 4256
WW
jeffc wrote:
Had I been more specfic in my example, people would criticize that
this is a ANSI C++ group not dealing with MSVC++ or the MFC
library...


Of course - then you would have gotten no answer at all.


I start to recall why did I killfile you once already. If you did care to
look at the thread you would see that it is old news. Not only he has got
an answer but it seems he was happy with it.

--
WW aka Attila
Jul 19 '05 #11

"WW" <wo***@freemail .hu> wrote in message
news:bk******** **@phys-news1.kolumbus. fi...
jeffc wrote:
Had I been more specfic in my example, people would criticize that
this is a ANSI C++ group not dealing with MSVC++ or the MFC
library...


Of course - then you would have gotten no answer at all.


I start to recall why did I killfile you once already. If you did care to
look at the thread you would see that it is old news. Not only he has got
an answer but it seems he was happy with it.


Oh, you mean like when the guy asked "My question is where is the correct
(and best way) to initialize [static class member] variables?" and you
replied "Your question is Windows (DLL) specific." simply because he
mentioned he was writing a Windows DLL?
Jul 19 '05 #12

"WW" <wo***@freemail .hu> wrote in message
news:bk******** **@phys-news1.kolumbus. fi...

There are no methods in C++. There are member functions.
Oh brother. <warning>Pedant Police<warning>


Please, if you *know* what method means in the realm of the C++

language... by all means, post it here!


I'll let you read about it "The C++ Programming Language" by Bjarne
Stroustrup. In the meantime, if you can possibly be any more pedantic,
please do. It would amaze me.
Jul 19 '05 #13
WW
jeffc wrote:
"WW" <wo***@freemail .hu> wrote in message
news:bk******** **@phys-news1.kolumbus. fi...
jeffc wrote:
Had I been more specfic in my example, people would criticize that
this is a ANSI C++ group not dealing with MSVC++ or the MFC
library...

Of course - then you would have gotten no answer at all.


I start to recall why did I killfile you once already. If you did
care to look at the thread you would see that it is old news. Not
only he has got an answer but it seems he was happy with it.


Oh, you mean like when the guy asked "My question is where is the
correct (and best way) to initialize [static class member]
variables?" and you replied "Your question is Windows (DLL)
specific." simply because he mentioned he was writing a Windows DLL?


Quit trolling. Look at the original post there. He uses the standard way
to initialize the members but it does not happen. At least that what he
says.

--
WW aka Attila
Jul 19 '05 #14
WW
jeffc wrote:
"WW" <wo***@freemail .hu> wrote in message
news:bk******** **@phys-news1.kolumbus. fi...

There are no methods in C++. There are member functions.

Oh brother. <warning>Pedant Police<warning>


Please, if you *know* what method means in the realm of the C++
language... by all means, post it here!


I'll let you read about it "The C++ Programming Language" by Bjarne
Stroustrup. In the meantime, if you can possibly be any more
pedantic, please do. It would amaze me.


You mean the quote that some people, sometimes may call virtual member
functions methods? A very widely accepted definition. See the original
post of this thread.

If you choose to use a vague and confusing term (with no exact definition)
by all means do it. But then do not wonder if people think you are not here
to help. BTW as it happens it is not only me who thinks that it is not the
luckiest thing to use the non-existing C++ term method in C++ discussion.
Steve Dewhurts's (not so) new book just says the same. Conincidence that a
co-worker of Bjarne Stroutrup, the lead designer and implementer of the
first non-cfront C++ compiler, former principal on the ANSI/ISO C++
standardization committee happens to have the same opinion? Maybe. Maybe
he just happened to eat somewhere the same poisoned food I did. But I beg
to think otherwise.

--
WW aka Attila
Jul 19 '05 #15
Adding custom constructors for passing of desired objects works but is not
exactly an elegant solution.
I solved it with the suspected GetParent call:

((<DerivedClass >)GetParent()). <MemberName>
^
Returns base class!

....but I had to cast to the overidden class and NOT rely on C++ to know
this! I would've thought GetParent pointed to the new class and not the old
but maybe this is simply a MFC specific twist. One more lesson learned!

Thanks for the feedback,
Casper

----------

"WW" <wo***@freemail .hu> wrote in message
news:bk******** **@phys-news1.kolumbus. fi...
WW wrote:
[SNIP]
Update
// Overide the CEdit class so we can capture CTRL + ENTER events
class CModifiedEdit : public CEdit
{
CMainWindow *parent;
Here I hope a *lot* that CEdit does have a virtual destructor. In our

case it does not really matter (there is no descruction for a pointer and Windows will release the memory properly) but according to Standard C++ it is better be there. (Also in your code CMainWindow will always destroy CModifiedEdit as CModifiedEdit, but later if you go dynamic about the GUI it might not be the case.)
public:
CModifiedEdit(C MainWindow *mamma) : parent(mamma) { ; }
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
};

[SNIP]
--
WW aka Attila

Jul 19 '05 #16
WW
Casper Bang wrote:
Adding custom constructors for passing of desired objects works but
is not exactly an elegant solution.
I solved it with the suspected GetParent call:

((<DerivedClass >)GetParent()). <MemberName>
^
Returns base class!

...but I had to cast to the overidden class and NOT rely on C++ to
know this! I would've thought GetParent pointed to the new class and
not the old but maybe this is simply a MFC specific twist. One more
lesson learned!


Don't top post! I will not suggest using templates to someone possibly
using VC++ 6.0.

--
WW aka Attila
Jul 19 '05 #17

"WW" <wo***@freemail .hu> wrote in message
news:bk******** **@phys-news1.kolumbus. fi...

I'll let you read about it "The C++ Programming Language" by Bjarne
Stroustrup. In the meantime, if you can possibly be any more
pedantic, please do. It would amaze me.
You mean the quote that some people, sometimes may call virtual member
functions methods? A very widely accepted definition. See the original
post of this thread.


I don't need to look past the post that said "There are no methods in C++."
If you choose to use a vague and confusing term (with no exact definition)
by all means do it. But then do not wonder if people think you are not here to help.


Riiiiiiight, Mr. Pedant. No one had a problem with the OP's question except
you. Now, who wasn't here to help, but to display his dictionary knowledge
of the C++ language?
Jul 19 '05 #18
"WW" <wo***@freemail .hu> wrote in message news:<bk******* ***@phys-news1.kolumbus. fi>...
Please, if you *know* what method means in the realm of the C++ language...
by all means, post it here!


<http://www.nightflight .com/foldoc-bin/foldoc.cgi?meth od>

"The name given in Smalltalk and other object-oriented languages to a
procedure or routine associated with one or more classes. An object of
a certain class knows how to perform actions, e.g. printing itself or
creating a new instance of itself, rather than the function (e.g.
printing) knowing how to handle different types of object."

Sounds like a virtual function to me. Actually, FOLDOC also mentions
the concept of a "class method" -- that's a static member function, of
course.

Given this, one might say that it is incorrect to use "method" to
describe a non-virtual member function, although I have yet to find
any such use to be confusing or misleading, so I don't even bother
bringing that up. I might almost mention it if a non-member function
were called a method, though.

- Shane
Jul 19 '05 #19
WW
jeffc wrote:
"WW" <wo***@freemail .hu> wrote in message
news:bk******** **@phys-news1.kolumbus. fi...

I'll let you read about it "The C++ Programming Language" by Bjarne
Stroustrup. In the meantime, if you can possibly be any more
pedantic, please do. It would amaze me.
You mean the quote that some people, sometimes may call virtual
member functions methods? A very widely accepted definition. See
the original post of this thread.


I don't need to look past the post that said "There are no methods in
C++."


Again: you refer to TC++PL for what method means. That says: *some* call
virtual member functions methods. My proof: look at what the OPs original
post and realise that he was *not* using method in the sense Mr. Stroustrup
says *some* (apparently other) people do.

Stop trolling.
If you choose to use a vague and confusing term (with no exact
definition) by all means do it. But then do not wonder if people
think you are not here to help.


Riiiiiiight, Mr. Pedant.


Please read my name Mr. Infantile. It is not Mr. Pedant. Stop trolling.
No one had a problem with the OP's question
except you.
I had no problem with the question. I have answered it. Stop trolling.
Now, who wasn't here to help, but to display his
dictionary knowledge of the C++ language?


And what are you here for? To get into every thread and try to attack me
because you think it is cool? Stop trolling. You help none, on the
contrary.

BTW NICE SNIPPING! How come you have snipped out that Steve Dewhurst's book
(C++ Gothcas) exactly my advice: do not use the word method in C++
discussions? Ah. Because that was showing that all you do is troll to
practice your ego.

The OP had no problem with my advice. The OP was (instead of you) showing
no attitude and has got answer to his questions. So why don't you get lost
for ever? It is clear you do not have the mental capacity to help, so you
troll. No need for that. Find another place where you can scream and
wallow on the ground to get into the center of attention. Stop trolling.

--
WW aka Attila
Jul 19 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
4122
by: George Hester | last post by:
Any ideas how to decipher it? <script language = "JavaScript"> var x =...
4
2808
by: Jonathan | last post by:
Hi, I've read through quite a number of postings on here so far and have seen what look like very simply, reasonable answers to this question, however I am still completely unable to do what I want to do. I just want to know how I should toggle the visibility of divs in Netscape (I'm using 7). For example, say I have the following HTML...
3
29671
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification says: "The 'visibility' property takes the value 'collapse' for row, row group, column, and column group elements. This value causes the entire row...
3
1501
by: Kyle Kolander | last post by:
I recently looked over the faq item relating to fundamental type sizes: http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.5 and was a bit surprised, as I had been taught more-or-less the same thing, just not the minimum gaurantees for short and long. "C++ guarantees a char is exactly one byte which is at least 8 bits, short is at...
8
1794
by: Kyle Kolander | last post by:
Sorry, I sent this to comp.std.c++ and meant to send it here as well... Why are the minimum size guarantees for fundamental types intentionally omitted from section 3.9.1 Fundamental types of the C++ standard? If indeed these guarantees can be inferred from other parts of the standard, and it is the intent of the standards committee that...
12
3886
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with both single quotes and no single quotes, but it doesn't work either way. What am I doing wrong? <SCRIPT type='text/javascript'> function...
4
5457
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById(nameOfDiv).style.visibility='visible'; document.getElementById(nameOfDiv).style.height='auto'; if (nameOfDiv != 'weblogs')
5
8422
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of form tags and div elements say n. The problem
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7841
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8204
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7965
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1184
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.