Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,397 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,229 people online right now. Registration is fast and FREE... Join Now!




Pls help me out...

2 Pages V  1 2 >  
Reply to this topicStart new topic

Pls help me out..., Blocks in c++

harish2rock
12 Feb, 2008 - 04:20 AM
Post #1

New D.I.C Head
*

Joined: 12 Feb, 2008
Posts: 6

Hi..Me just a beginner in c++ programming.
I have come acroos a program which is as follows :
- >Has the concept of Blocks.(whats that ?).
Has one main class A with data members and functions.
It now includes another class B inside this main class and has its own members and functions. The inner class B now ends after which the main class A terminates..
Its like this :
BEGIN A

members
functions()

BEGIN B

members
functions()

END B

END A

So guys, pls suggest me as to how to write the code for this porgram logic ?
Me in a big dilemma over it..

And thanks in advance..
User is offlineProfile CardPM
+Quote Post

bhandari
RE: Pls Help Me Out...
12 Feb, 2008 - 05:04 AM
Post #2

D.I.C Addict
Group Icon

Joined: 31 Jan, 2008
Posts: 747


Dream Kudos: 900
My Contributions
what's your progress??
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Pls Help Me Out...
12 Feb, 2008 - 05:05 AM
Post #3

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,347



Thanked: 51 times
Dream Kudos: 25
My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: code.gif

Thanks.
User is online!Profile CardPM
+Quote Post

Trogdor
RE: Pls Help Me Out...
12 Feb, 2008 - 06:03 AM
Post #4

D.I.C Addict
Group Icon

Joined: 6 Oct, 2006
Posts: 549



Thanked: 4 times
Dream Kudos: 125
My Contributions
{}
User is offlineProfile CardPM
+Quote Post

AmitTheInfinity
RE: Pls Help Me Out...
12 Feb, 2008 - 06:07 AM
Post #5

C Surfing ∞
Group Icon

Joined: 25 Jan, 2007
Posts: 1,153



Thanked: 44 times
Dream Kudos: 125
My Contributions
QUOTE(Trogdor @ 12 Feb, 2008 - 07:33 PM) *

{}


lol... that's a huge progress. All he needs to do is put the code inside it and function name outside it. whoala.... you are done. tongue.gif bigsmile.gif
User is offlineProfile CardPM
+Quote Post

harish2rock
RE: Pls Help Me Out...
12 Feb, 2008 - 09:37 AM
Post #6

New D.I.C Head
*

Joined: 12 Feb, 2008
Posts: 6

class PANELDATA
{
class title
{
public:
void description()
{
cout << "Panel Method for Runway no. 312" <<\n << "Intended for Saras Wing Aircraft" ;
//multiline text
}
};
};

main()
{
//Body
}

Does the code given above adher to what the program logic states ? Its there in the 1st post of this topic..
User is offlineProfile CardPM
+Quote Post

letthecolorsrumble
RE: Pls Help Me Out...
12 Feb, 2008 - 10:16 AM
Post #7

Student of The Sun
Group Icon

Joined: 7 Nov, 2007
Posts: 550



Thanked: 1 times
My Contributions
QUOTE(harish2rock @ 12 Feb, 2008 - 10:37 AM) *

class PANELDATA
{
class title
{
public:
void description()
{
cout << "Panel Method for Runway no. 312" <<\n << "Intended for Saras Wing Aircraft" ;
//multiline text
}
};
};

main()
{
//Body
}

Does the code given above adher to what the program logic states ? Its there in the 1st post of this topic..

CODE

#include <iostream>/*change -1*/

using namespace std; /*change 0*/

class PANELDATA {
    public:                                          /*change 1*/
        class TITLE {
            public:
                void description(){
                    cout << "Panel Method for Runway no. 312" <<endl<< "Intended for Saras Wing Aircraft";    /*change 2*/
                    //multiline text
                }

        };

};

int main(){              /*change 3*/
    PANELDATA::TITLE pdt;
    pdt.description();

    return 0; /*change 4*/
}


I don't know how much you know about programming so I will explain all the changes smile.gif .
Here they go:
change -1 : include header files to use pre-defined functions.
change 0 : using namespace std; to use certain commands like cout etc.
change 1 : if you want to access anything inside a child class you need to define the child class as public.
change 2 : use endl instead of \n , you can still use \n inside strings.
change 3 : most compilers in c++ expect a return value from the main function. normally a warning
comes up.
change 4 : return 0; returns an int value at the end of the main function

User is offlineProfile CardPM
+Quote Post

bhandari
RE: Pls Help Me Out...
12 Feb, 2008 - 10:07 PM
Post #8

D.I.C Addict
Group Icon

Joined: 31 Jan, 2008
Posts: 747


Dream Kudos: 900
My Contributions
so finally harish is getting to it. Good going.
User is offlineProfile CardPM
+Quote Post

harish2rock
RE: Pls Help Me Out...
12 Feb, 2008 - 11:14 PM
Post #9

New D.I.C Head
*

Joined: 12 Feb, 2008
Posts: 6

No guys...Am still not getting at it.
Seems the code must adher to the following :
I have to prepare a file which contains the information in block format. as an example, the file will look like so:

BEGIN PANELDATA
BEGIN TITLE
Panel Method for Saras Analsis.
Run number 22.
END TITLE
END PANELDATA

this information will be stored in a file. let us call this file SampleInput.dat. our program must scan this information as blocks. we have two blocks in this example. the outermost block has name PANELDATA. this block contain one block named TITLE. title block contains information. in this case the information is stored as multiline text.

consider another example of an input file. let us call this SampleInput2.dat. It may look like so:

BEGIN PANELDATA
BEGIN TITLE
Panel Method for Saras Analsis.
Run number 22.
END TITLE

BEGIN FLIGHTPARAMETERS
3
Mach_number (d) Flight_speed (d) num_Panels (i)
0.8 1.0 2287
END FLIGHTPARAMETERS
END PANELDATA


in this case, the main block, viz., PANELDATA, has two block in it. the FLIGTHPARAMETERS block contains information. the first entry, viz., 3, tells us that there are 3 entries. the next line shows the names and type of those entries. for instance, the name of the first data is Mach_number and its type is double indicated by (d). similarly, num_Panels is the name of the third entry whose type is integer. the next line contains the numerical values. thus, the FLIGHTPARAMETERS block has more extensive structure. The application should first be able to scan through such files, figure out how many blocks are there and what are their types. if the type of a block is TITLE, then we expect multiline text. if the type of block is FLIGHTPARAMETERS, then we expect number of entries, description of entries and the entries themselves. in the same way, more blocks will be added as we go on.

So how to do the coding for this ? Me just clueless..
Pls do help me out...
User is offlineProfile CardPM
+Quote Post

harish2rock
RE: Pls Help Me Out...
13 Feb, 2008 - 07:54 AM
Post #10

New D.I.C Head
*

Joined: 12 Feb, 2008
Posts: 6

Pls do anyone reply something guys...

User is offlineProfile CardPM
+Quote Post

Trogdor
RE: Pls Help Me Out...
13 Feb, 2008 - 08:56 AM
Post #11

D.I.C Addict
Group Icon

Joined: 6 Oct, 2006
Posts: 549



Thanked: 4 times
Dream Kudos: 125
My Contributions
So the data must be stored in files, and your program must read those files.
Time to open your C/C++ book on the chapter "File IO" and have a go.
Once you understand that, coding out your problem will be cake.
User is offlineProfile CardPM
+Quote Post

harish2rock
RE: Pls Help Me Out...
14 Feb, 2008 - 07:59 PM
Post #12

New D.I.C Head
*

Joined: 12 Feb, 2008
Posts: 6

Hi Letthecolorscrumble,

Pls do help me out..
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Reply to this topicStart new topic
Time is now: 1/7/09 10:14AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month