Design..

Hi,
I've learnt c++ and mfc and im building a program that is using both, but 
i,mm having a problem combining all the code together.
this is my first serious progect using them, and im having a problem in code 
design and it goes as follows:

how can if i have file "a.cpp" that is connected to a "a.h" file(c++ class 
files) and i have file "f.cpp" and "f.h" how can i make f which is the main 
program use the class i have in "a".

thanks.



0
fkpkot (25)
11/21/2005 6:05:29 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
675 Views

Similar Articles

[PageSpeed] 16

> I've learnt c++ and mfc and im building a program that is using both,

MFC is written is C++. So when you are using MFC, you are using C++.

>how can if i have file "a.cpp" that is connected to a "a.h" file(c++ class files)

What do you mean by connected? There is no connectioin other than the
fact the file can be included in any other file. You tend to name the
header file same as cpp because it typically contains class declaration
and implementation/definition is in cpp.

> i have file "f.cpp" and "f.h" how can i make f which is the main
>program use the class i have in "a".

You can use #include "a.h" in your f.cpp or f.h.

---------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6842)
11/21/2005 6:18:29 PM
fima wrote:

> Hi,
> I've learnt c++ and mfc and im building a program that is using both, but 
> i,mm having a problem combining all the code together.
> this is my first serious progect using them, and im having a problem in code 
> design and it goes as follows:
> 
> how can if i have file "a.cpp" that is connected to a "a.h" file(c++ class 
> files) and i have file "f.cpp" and "f.h" how can i make f which is the main 
> program use the class i have in "a".
> 
> thanks.
> 
> 
> 
fima:

Rules to live by:

1. If class F has an object of class A as a member, then you should 
include a.h in f.h

2. If class F has a pointer to an object of class A as a member, or has 
methods that take a pointer to A as a parameter, then you should use 
forward declaration of class A in f.h, and include a.h in f.cpp.

3. If class F uses class A only as a local object in a method, then you 
need only include a.h in f.cpp. This is often true when A is a dialog 
which you are invoking with DoModal().

HTH,

David Wilkinson
0
no-reply8010 (1791)
11/21/2005 7:16:45 PM
Reply:

Similar Artilces:

OT: RTF Question: Is this a bug or by design?
This could be considered slightly off-topic, so I'm sorry. But everyone here always provides great feedback, so I'd like your thoughts. In Vista, customize your visual Theme to use a "classic appearance" and select "High Contrast Black". Open Wordpad (which uses an RTF Control/View). Type some text and print it. You'll see the text gets printed, inheriting your visual style, white text on a black background. Set the same Visual Theme win Windows XP and open Wordpad, type some text and print it. You get Black Text on a white background. The behavior in ...

Designing Print Styles for Forms
I am using Outlook 2002, OS is Windows XP, and I have created a custom form. I need to create a print style that will allow me to define which fields and labels are printed and the location of the fields on the printed page. Any help will be greatly appreciated. Thanks. ...

Template design
I have a dialog bar, that has 1. drop down list for VARIABLE selection 2. drop down list for OPERATOR selection 3. text box for the user to enter VALUE. Variable can be of any type: int, float, string, etc Operator can be +, -, ++, =, ==, !=, (See below for list of operators) Value should be stored in the format whatever the variable's data type is of So, if a user selects Variable: id(int), Operator: ==, Value: 50 should send "id == 50" as a constraint to the program Variable: name(String), Operator !=, Value: "Test" should send "name != test" List of ope...

blank cd cover designs
Looking for some cool cd cover designs for all types of music "OL' MUSIC LOVER" <OL' MUSIC LOVER@discussions.microsoft.com> wrote in message news:92CA53B2-8A1B-43CB-A087-60535D52C0E7@microsoft.com... > Looking for some cool cd cover designs for all types of music Google it. I don't want to... http://office.microsoft.com/en-us/templates/CT011387531033.aspx -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "OL' MUSIC LOVER" <OL' MUSIC LOVER@discussions.microsoft.com> wrote in me...

help designing query to get results
In my database of employees I have three date/time fields - Agency Start date, Rehire date (a lot of our employees only work part of the year) and Separation Date. If I wanted to show only the employees who have either started, were rehired or separated in a certain time frame, how would I do that? Example: Which employees started or were rehired or separted between july 1 and july 30? -- JoAnn In query design view, enter the date range in the Criteria row under the first date field. Below the Criteria row, you'll see another one marked Or. Enter the same date range...

Design Gallery and Publisher 2000 with Win XP Pro
I just recently started having this problem. When I open Publisher 2000 in my Win XP Pro machine all goes well until I click on Design Gallery. From that point on the program is unresponsive. The only way to exit is to use End Task at which point it tells me that Publisher is unresponsive because there is a dialogue box open and it is waiting for a response from me. That isn't so because Design Gallery never did open up. I have tried to repair Publisher without results. I have uninstalled Publisher as well and reinstalled without any improvements either. As a last hope I reinstal...

First time using Publisher to design website
I created a form in publisher but I don't know where to add in the scripts so it will run. Any help would be appreciated. Publisher web publication forms 101 http://msmvps.com/blogs/dbartosik/archive/2006/01/07/80564.aspx and reference the articles on uploading, and specifically HTTP protocol: http://msmvps.com/blogs/dbartosik/articles/category/1921.aspx DavidF "Help with Publisher for Webdesign" <HelpwithPublisherforWebdesign@discussions.microsoft.com> wrote in message news:06203845-2F98-451A-AF8E-054C14E83E97@microsoft.com... > I created a form in publisher but I ...

Subclassed scrollbar design question
I have an app that uses a lot of custom controls. I subclassed a CStatic to create a scroll bar control, which I use on some of my dialogs. On one of these dialogs the custom scrollbar is the scrollbar for a list box on the same dialog. As a general design question, is it better to pass the handle of the list box to the scroll bar and let the bar control the list? Or is it better to have the scrollbar send the WM_COMMAND message back to its parent and have the parent control the list? Or is either way (if properly done) correct? Thanks, Dan. "Dan McCarty" wrote: > I have ...

navigate tab pages in design view
existing 03 form has tabbed pages; in form view user moves w/ buttons that ..setfocus to the correct tab page in design view only the main form controls show and can't find any handle to go to the other pages and their controls.... any ideas? tia -- NTC Just click on the tab you want to see. -- Dave Hargis, Microsoft Access MVP "NetworkTrade" wrote: > existing 03 form has tabbed pages; in form view user moves w/ buttons that > .setfocus to the correct tab page > > in design view only the main form controls show and can't find any handle to > go t...

Help needed with table design/layout for newbie
Hi, i have just joined the forum and have built a few DB's in the past but found i have forgotten almost everything! I do remember with a previous DB i layed the tables out incorrectly which impacted on the flexibility down the line so would like advise before i start in order to get a good foundation. My dB is for our watersports centre to book people onto courses and retain their details in a contacts table to be imported to Outlook for mailing info. We run various courses which then run on multiple dates across the year. So for example we may run a Powerboat Level 1 course, this...

Book for Exchange Design
Im looking to get my messeging specialization and was wondering if anyone can recomend a good book for the design exam. Thanks Kev Check these out, http://www.msexchange.org/pages/books.asp Cheers oz -- Best regards, Good Luck Oz Ozugurlu ____________________________ MCSE 2003 M+,S+, CCNA Http://www.msexchange911.org Http://www.consultusa.us (Blog) "Kev" wrote: > Im looking to get my messeging specialization and was wondering if anyone can > recomend a good book for the design exam. > > Thanks > > Kev On Mon, 17 Apr 2006 05:22:01 -0700, Kev <Kev@di...

Can't see design view
Hi there, I have inherited a db and need to make changes. The problem is that I can't get to the form's design view, the command is greyed out. I'm not prompted for a password so I don't think there are user permissions. What would likely get me into design view? Thanks! -- www.brightfuture.ca/bright My email address can be found on my site. Are you opening the db while holding down a <SHIFT> key? Johnny Bright wrote: >Hi there, > >I have inherited a db and need to make changes. The problem is that I can't >get to the form's design view, t...

Efficient Table Design Questions
I'm working on a Project Manager DBase for our engineering department. One of the things they want to be able to record within each project is the Size, Length and Material of the pipes installed. They also want to be able to run reports that would provide them totals based upon region, year, etc. So I'm looking at sizes ranging from 1/2" to 48" (approx 20 different sizes) plus a wide range of possible materials for each size. Question 1: Since a project could have multiple materials of the same pipe size installed, do I create a field for each possible siz...

New
I whipped up this little article that shows users how to use the My Objects tab in the little known Design Gallery (not available in the remainder of Office). http://www.publishermvps.com/DesignGalleryCustomization/tabid/167/Default.aspx -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com This posting is provided "AS IS" with no warranties, and confers no rights. ...

Can I insert a swf file or any flash file to Publisher design?
Can I insert a swf file or any flash file to Publisher design? And how will the ink move? "Mr_M" <Mr_M@discussions.microsoft.com> wrote in message news:42C848E5-FD1D-4085-A1E3-4CD0D5C81374@microsoft.com... | Can I insert a swf file or any flash file to Publisher design? Only if you plan to incorporate the .swf into a web page. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com http://officebeta.iponet.net/en-us/publisher/FX100649111033.aspx "Mr_M" <Mr_M@discussions.microsoft.com> wrote in message ...

How can I design my own templates for in publisher
I want to know how to design a template for in publisher. It will be for a DVD case jacket. Basically what I want to make is a rectangle with 2 lines down the center for the spine. I'd like to have the lines so that they would appear unmoveable to function as a guide but would not be printed. Thnx:) While waiting for decisions from his 6 university choices, Ed sees a message from Neil <Neil@discussions.microsoft.com>. On it is written: > I want to know how to design a template for in publisher. It will be > for a DVD case jacket. Basically what I want to make is a rectangle...

sharepoint designer 2010 beta won't install
I installed Office and Visio 2010 beta (on windows 7) with no issues. However, when I try the Sharepoint Designer 2010 beta, it doesn't work. When I try to run it, the installer extracts files then terminates silently. I tried the same thing on my test windows 7 x64 vm with the same issue. These messages appear in the application log: Log Name: Application Source: MsiInstaller Date: 12/31/2009 11:48:38 AM Event ID: 1004 Task Category: None Level: Warning Keywords: Classic User: N/A Computer: home-pc Description:...

Inheritied Serializable Classes (OOP Design)
I have base classes defined in a hierarchy structure which all have XMLElementAttributes on them and marked as Serializable. I then have classes which inherit from the base classes and hide some of the base class properties using the "new" keyword in order to redefine the schema. Every time I go to serialize the object I get exceptions about hiding base class member X of type Y. Use XmlElementAttribute or XmlAttributeAttribute to specify a new name. What do I need to do to overcome this in the serializer or is this an MS limitation in the XML Serializer??? The code compil...

Including Null values in query design
I am using a form to enter the parameters for a report. The parameters are drawn from a number of combo boxes on the form. The report is based on a query. Several of the query fields have expressions such as: Like IIf(IsNull([forms]![frmReports]![cboIssuedBy]),"*",([forms]! [frmReports]![cboIssuedBy])). This works fine as long as the fields that are being queried have no null values - if they do, then in the situation where I want the "*" to apply, the query only returns the records which have a value. Really, I want to be able to replace the "*" pa...

GUI/Service design and use of SetServiceObjectSecurity
Hello, I'm splitting an application into application and service components. Part of the normal application's responsibilities are best allowed to run while the user is not logged on. I'd like to keep this change as invisible as possible to the user. The only activity that would give the service side a problem is the ability to print. If the user chooses to set up a network printer, the service will need to run under the user's account and not under the Local System Account. Ideally, when the user configures the application for printing, it would also set the information ...

Alterations in Form Design Cause Crash
Hi there, I have recently deployed a database, and am having issues in that every time a form is opened and altered in design mode, it causes some type of corruption and requires redeployment. The error message gives no number and just states that "There was an error executing the command". I have compiled and compacted/repaired the database multiple times, but this is happening a lot. I've also had this occur in other databases, for not apparent reason. The situation doesn't seem to discriminate based upon whether a database is split or not. I've also tried ...

Publisher - printer won't print A4 designs
(on XP) Publisher 2003 won't print A4 - keeps reverting to "Letter" . I have tried altering all the settings I can, but it doesn't work. If I print the item on another computer it works!! Help - it's driving me mad. Have you checked the Printer Properties of the Printer in the Control Panel? -- Rae Drysdale "Gill Goodwin" wrote: > (on XP) Publisher 2003 won't print A4 - keeps reverting to "Letter" . I have > tried altering all the settings I can, but it doesn't work. If I print the > item on another computer it works!! Hel...

Altium Designer vs. Cadence Allegro & Cadence Orcad.
Dr. Marty, Was your reply pre-formulated by the sales department (or what's left of it) or your marketing folks (which are good)? Based on your reply I did my homework as well. First I tried to talk myself into reading something positive in what you guys just did. Then I did some research. Forgive me my stupidity... I am just an engineer, which makes me wonder "what makes me so important"? Apparently my banking account. Is it my naivity buying tools from a small vendor? I thought your organisation is strong enough. But now I have tools I paid 2.5x of what I should hav...

Database Design 01-13-10
This is a database design question. I need to provide an analogy of what I'm trying to do. Imagine there are 10 types of products - call them A - J. Products A - F have a characteristic that is further defined in another table - call that table T and that field Q. Products G - J don't have that. I want to link that field in the product table to the corresponding field in table T so I can query all products where Q = 22. But since some of the products don't use the field - this won't work. I could also create separate tables - one table for products A - F an...

Show / hide design grid
For some reason thedesign grid in one of the queries that I have created disappears. I can still see the tables and queries upon which the query in question is based but the actual design grid has gone. The grid cannot be located by doing a grid search using the scroll bars (all the way to the bottom; across to the right one step; all the way to the top; across to the right one more step\; etc etc) I cannot find any setting that will restore the query design grid and cannot find any reference to it on Google either. I have Googled "Show hide query design grid", "Cannot see...