473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Any c++ pros out there?

Here's my problem, i need to do a c++ program for my project at
school using structures. All my friends have submitted theirs and no
two should have the same project. jus' gi mme an out of the box idea
please. i can do with writing the source code.

Mar 26 '06 #1
22 1426
On 26 Mar 2006 06:13:26 -0800, ra*********@googlemail.com wrote:
Here's my problem, i need to do a c++ program for my project at
school using structures. All my friends have submitted theirs and no
two should have the same project. jus' gi mme an out of the box idea
please. i can do with writing the source code.


Here's a good structure:

struct empty
{
};
Mar 26 '06 #2
ra*********@googlemail.com wrote:
Here's my problem, i need to do a c++ program for my project at
school using structures. All my friends have submitted theirs and no
two should have the same project. jus' gi mme an out of the box idea
please. i can do with writing the source code.


Maybe you should go to your professor to get some inspiration. From my
experience they are usually willing to give you that kind of help.
For people in the newsgroup, it's a bit hard to give you some suggestions,
because you didn't say how much time is planned, if you're doing it alone
or in a group and whether you may (or even must?) use some external
libraries.

Mar 26 '06 #3

Rolf Magnus wrote:
ra*********@googlemail.com wrote:
Here's my problem, i need to do a c++ program for my project at
school using structures. All my friends have submitted theirs and no
two should have the same project. jus' gi mme an out of the box idea
please. i can do with writing the source code.


Maybe you should go to your professor to get some inspiration. From my
experience they are usually willing to give you that kind of help.
For people in the newsgroup, it's a bit hard to give you some suggestions,
because you didn't say how much time is planned, if you're doing it alone
or in a group and whether you may (or even must?) use some external
libraries


Actually this is a group(max 4) project and has to be completed within
end of may.
all my friends have already proposed their ideas to the prof. and as
there should'nt be any repetition everybody has to get an unusual idea.

i did my part really well. i went to her and told about a program which
would accept a sentence and give an output of the same sentence in
morse code(using different delay times in the frequencies) but
unfortunately someone had proposed the idea earlier, that just kept me
wondering whether i could get another idea such as that.
please help!!!!

Mar 26 '06 #4
W Marsh wrote:
On 26 Mar 2006 06:13:26 -0800, ra*********@googlemail.com wrote:
Here's my problem, i need to do a c++ program for my project at
school using structures. All my friends have submitted theirs and no
two should have the same project. jus' gi mme an out of the box idea
please. i can do with writing the source code.


Here's a good structure:

struct empty
{
};


In order to make this more useful, you should provide a better interface.
This is what I use:

struct empty {};

std::ostream & operator<< ( std::ostream & ostr, empty const & e ) {
return( ostr << '#' );
}

std::istream & operator>> ( std::istream & istr, empty & e ) {
char chr;
istr >> chr;
if ( chr != '#' ) {
istr.setstate( std::ios_base::failbit );
}
return( istr );
}

bool operator== ( empty a, empty b ) {
return( true );
}

bool operator!= ( empty a, empty b ) {
return( false );
}

bool operator< ( empty a, empty b ) {
return( false );
}

bool operator<= ( empty a, empty b ) {
return( true );
}

bool operator> ( empty a, empty b ) {
return( false );
}

bool operator>= ( empty a, empty b ) {
return( true );
}
Best

Kai-Uwe Bux
Mar 26 '06 #5

Kai-Uwe Bux wrote:
W Marsh wrote:
On 26 Mar 2006 06:13:26 -0800, ra*********@googlemail.com wrote:
Here's my problem, i need to do a c++ program for my project at
school using structures. All my friends have submitted theirs and no
two should have the same project. jus' gi mme an out of the box idea
please. i can do with writing the source code.


Here's a good structure:

struct empty
{
};


In order to make this more useful, you should provide a better interface.
This is what I use:

struct empty {};

std::ostream & operator<< ( std::ostream & ostr, empty const & e ) {
return( ostr << '#' );
}

std::istream & operator>> ( std::istream & istr, empty & e ) {
char chr;
istr >> chr;
if ( chr != '#' ) {
istr.setstate( std::ios_base::failbit );
}
return( istr );
}

bool operator== ( empty a, empty b ) {
return( true );
}

bool operator!= ( empty a, empty b ) {
return( false );
}

bool operator< ( empty a, empty b ) {
return( false );
}

bool operator<= ( empty a, empty b ) {
return( true );
}

bool operator> ( empty a, empty b ) {
return( false );
}

bool operator>= ( empty a, empty b ) {
return( true );
}
Best

Kai-Uwe Bux

nice try dude!

Well a program with structure is something which everybody can do but,
wat i need to do is a program which can be used in real life, not just
something which returns true/ false

Mar 26 '06 #6
In article <11**********************@z34g2000cwc.googlegroups .com>,
ra*********@googlemail.com wrote:
Here's my problem, i need to do a c++ program for my project at
school using structures. All my friends have submitted theirs and no
two should have the same project. jus' gi mme an out of the box idea
please. i can do with writing the source code.


So you need an interesting problem that can be done in about a month by
four beginners?

How about one of the exorcises from Bjarne Stroustrup's book?

Exorcise 2 from section 12.7 should be quite interesting.
--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Mar 26 '06 #7
rAgAv wrote:

Kai-Uwe Bux wrote:
W Marsh wrote:
> On 26 Mar 2006 06:13:26 -0800, ra*********@googlemail.com wrote:
>
>> Here's my problem, i need to do a c++ program for my project at
>>school using structures. All my friends have submitted theirs and no
>>two should have the same project. jus' gi mme an out of the box idea
>>please. i can do with writing the source code.
>
> Here's a good structure:
>
> struct empty
> {
> };


In order to make this more useful, you should provide a better interface.
This is what I use:

struct empty {};

std::ostream & operator<< ( std::ostream & ostr, empty const & e ) {
return( ostr << '#' );
}

std::istream & operator>> ( std::istream & istr, empty & e ) {
char chr;
istr >> chr;
if ( chr != '#' ) {
istr.setstate( std::ios_base::failbit );
}
return( istr );
}

bool operator== ( empty a, empty b ) {
return( true );
}

bool operator!= ( empty a, empty b ) {
return( false );
}

bool operator< ( empty a, empty b ) {
return( false );
}

bool operator<= ( empty a, empty b ) {
return( true );
}

bool operator> ( empty a, empty b ) {
return( false );
}

bool operator>= ( empty a, empty b ) {
return( true );
}
Best

Kai-Uwe Bux

nice try dude!

Well a program with structure is something which everybody can do but,
wat i need to do is a program which can be used in real life, not just
something which returns true/ false


You may fail to see the significance, however, the code above is directly
copied from my library and has proved to be useful in the past. I leave it
up to your imagination (or your skillful use of Google) to figure out why
you may want a class like this.
As for something you might try: implement a box-container (also something
that proved useful in my library; and I know it can be done with a
reasonable amount of effort):

Specifications:

template < typename T >
class box;

A box can be empty or contain an element of type T. Boxes are default
constructible (yielding the empty box), copy-constructible, assignable.
Also, comparisons for boxes are defined:

the empty box is greater than any non-empty box.
non-empty boxes compare according to content.

Finally, box<T> has members:

bool empty () const; // returns true if the box is empty.
T & item (); // returns a handle to the contents.
T const & item () const; // returns a handle to the contents.
void clear(); // empties the box.
void put ( T const & t ); // puts a copy of t into the box.
box<T> ( T const & t ); // construct a box containing a copy of t.

Maybe that qualifies as an "out of the box idea".
Best

Kai-Uwe Bux
Mar 26 '06 #8
ra*********@googlemail.com wrote:
-snip-
i did my part really well. i went to her and told about a program which
would accept a sentence and give an output of the same sentence in
morse code(using different delay times in the frequencies) but
unfortunately someone had proposed the idea earlier, that just kept me
wondering whether i could get another idea such as that.
please help!!!!


Then make a program that converts morse code back again to something
understandable.
Best regards / Med venlig hilsen
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Mar 26 '06 #9
Daniel T. wrote:

How about one of the exorcises from Bjarne Stroustrup's book?


Do you think C++ could save Emily Rose? ;)

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Mar 27 '06 #10
>> How about one of the exorcises from Bjarne Stroustrup's book?

Do you think C++ could save Emily Rose? ;)


#define EXORCISM(x) ((void)0)

Patrick
Mar 27 '06 #11
In message <e0**********@murdoch.acc.Virginia.EDU>, Kai-Uwe Bux
<jk********@gmx.net> writes
W Marsh wrote:
On 26 Mar 2006 06:13:26 -0800, ra*********@googlemail.com wrote:
Here's my problem, i need to do a c++ program for my project at
school using structures. All my friends have submitted theirs and no
two should have the same project. jus' gi mme an out of the box idea
please. i can do with writing the source code.


Here's a good structure:

struct empty
{
};


In order to make this more useful, you should provide a better interface.
This is what I use:

struct empty {};

std::ostream & operator<< ( std::ostream & ostr, empty const & e ) {
return( ostr << '#' );
}

std::istream & operator>> ( std::istream & istr, empty & e ) {
char chr;
istr >> chr;
if ( chr != '#' ) {
istr.setstate( std::ios_base::failbit );
}
return( istr );
}

bool operator== ( empty a, empty b ) {
return( true );
}

bool operator!= ( empty a, empty b ) {
return( false );
}

bool operator< ( empty a, empty b ) {
return( false );
}

bool operator<= ( empty a, empty b ) {
return( true );
}

bool operator> ( empty a, empty b ) {
return( false );
}

bool operator>= ( empty a, empty b ) {
return( true );
}

You could remove the need for a few of the above by judicious use of

#include <utility>
using namespace rel_ops;

;-)

--
Richard Herring
Mar 29 '06 #12

Martin Jørgensen wrote:
ra*********@googlemail.com wrote:
-snip-
i did my part really well. i went to her and told about a program which
would accept a sentence and give an output of the same sentence in
morse code(using different delay times in the frequencies) but
unfortunately someone had proposed the idea earlier, that just kept me
wondering whether i could get another idea such as that.
please help!!!!


Then make a program that converts morse code back again to something
understandable.


C'mon man how will you ever input a *morse code* in ur black screen,
gone crazy or wat!!!!!!?
I'd recommand a tutorial in c++ for u.

Apr 6 '06 #13
My god, I found this thread VERY funny. I apologize for that. =)

Apr 6 '06 #14
On Sun, 26 Mar 2006 14:00:41 -0500 Kai-Uwe Bux <jk********@gmx.net>
waved a wand and this message magically appeared:
Finally, box<T> has members:

bool empty () const; // returns true if the box is empty.
T & item (); // returns a handle to the contents.
T const & item () const; // returns a handle to the contents.
void clear(); // empties the box.
void put ( T const & t ); // puts a copy of t into the box.
box<T> ( T const & t ); // construct a box containing a copy of t.

Maybe that qualifies as an "out of the box idea".


Out of sheer boredom, I put this one together:
#include <iostream>

template <typename T>
class Box
{
public:
Box();

bool empty() const;
T& item();
T const& item() const;
void clear();
void put(T const& t);

private:
T object;
};

template <typename T>
Box<T>::Box()
{
object = T();
}

template <typename T>
bool Box<T>::empty() const
{
if (object.size() > 0)
return false;

return true;
}

template <typename T>
T& Box<T>::item()
{
return object;
}

template <typename T>
T const& Box<T>::item() const
{
return object;
}

template <typename T>
void Box<T>::clear()
{
object = T();
}

template <typename T>
void Box<T>::put(T const& t)
{
object = t;
}

int main()
{
Box<std::string> box;

box.put("cat");

if (box.empty())
std::cout << "Box is empty!" << std::endl;
else
std::cout << "Cat scratches you on the arm!" <<
std::endl;

return 0;
}

--
http://www.munted.org.uk

Take a nap, it saves lives.
Apr 6 '06 #15
REH

rAgAv wrote:
C'mon man how will you ever input a *morse code* in ur black screen,
gone crazy or wat!!!!!!?
I'd recommand a tutorial in c++ for u.


di-di-di-dah-dah-dah-di-di-dit
REH

Apr 6 '06 #16
REH wrote:
rAgAv wrote:
C'mon man how will you ever input a *morse code* in ur black screen,
gone crazy or wat!!!!!!?
I'd recommand a tutorial in c++ for u.


di-di-di-dah-dah-dah-di-di-dit


I thought it was

pip-pip-pip-PEEP-PEEP-PEEP-pip-pip-pip

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 6 '06 #17
Victor Bazarov <v.********@comacast.net> wrote:
REH wrote:
rAgAv wrote:
C'mon man how will you ever input a *morse code* in ur black screen,
gone crazy or wat!!!!!!?
I'd recommand a tutorial in c++ for u.


di-di-di-dah-dah-dah-di-di-dit


I thought it was

pip-pip-pip-PEEP-PEEP-PEEP-pip-pip-pip


Well, according to http://en.wikipedia.org/wiki/Morse_code , it's dit's
and dah's, but now we're starting to get OT.

A little bit closer to topicality, there is an obfuscated C program that
can translate both to and from Morse code on the IOCCC page (look for
the 1998 entry by dorssel: http://www.ioccc.org/years-spoiler.html#1998 )

--
Marcus Kwok
Apr 6 '06 #18
REH

Marcus Kwok wrote:
Well, according to http://en.wikipedia.org/wiki/Morse_code , it's dit's
and dah's, but now we're starting to get OT.

Marcus Kwok


Only at the end of a sequence.

http://home.clara.net/rod.beavon/morse.htm

REH

Apr 6 '06 #19
Alex Buell wrote:
On Sun, 26 Mar 2006 14:00:41 -0500 Kai-Uwe Bux <jk********@gmx.net>
waved a wand and this message magically appeared:
Finally, box<T> has members:

bool empty () const; // returns true if the box is empty.
T & item (); // returns a handle to the contents.
T const & item () const; // returns a handle to the contents.
void clear(); // empties the box.
void put ( T const & t ); // puts a copy of t into the box.
box<T> ( T const & t ); // construct a box containing a copy of t.

Maybe that qualifies as an "out of the box idea".


Out of sheer boredom, I put this one together:
#include <iostream>

template <typename T>
class Box
{
public:
Box();

bool empty() const;
T& item();
T const& item() const;
void clear();
void put(T const& t);

private:
T object;
};

template <typename T>
Box<T>::Box()
{
object = T();
}

template <typename T>
bool Box<T>::empty() const
{
if (object.size() > 0)
return false;

return true;
}

template <typename T>
T& Box<T>::item()
{
return object;
}

template <typename T>
T const& Box<T>::item() const
{
return object;
}

template <typename T>
void Box<T>::clear()
{
object = T();
}

template <typename T>
void Box<T>::put(T const& t)
{
object = t;
}

int main()
{
Box<std::string> box;

box.put("cat");

if (box.empty())
std::cout << "Box is empty!" << std::endl;
else
std::cout << "Cat scratches you on the arm!" <<
std::endl;

return 0;
}


Your solution does not distinguish an empty box<T> from a box that contains
the default value for T, i.e., a box<int> that contains 0 is considered
empty.
Best

Kai-Uwe Bux
Apr 7 '06 #20
Kai-Uwe Bux wrote:
Your solution does not distinguish an empty box<T> from a box that
contains
the default value for T, i.e., a box<int> that contains 0 is considered
empty.


I just tuned in. Are you guys reinventing Barton & Nackman's Fallible<T>
from their Scientific and Engineering Something C++ book?

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Apr 7 '06 #21
Phlip wrote:
Kai-Uwe Bux wrote:
Your solution does not distinguish an empty box<T> from a box that
contains
the default value for T, i.e., a box<int> that contains 0 is considered
empty.


I just tuned in. Are you guys reinventing Barton & Nackman's Fallible<T>
from their Scientific and Engineering Something C++ book?


I don't know. What does that thing do?
Best

Kai-Uwe Bux
Apr 7 '06 #22

Marco Costa wrote:
My god, I found this thread VERY funny. I apologize for that. =)


Not ur mistake. It IS funny!!!!

Apr 7 '06 #23

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

Similar topics

0
by: Sniffle | last post by:
Thanks... Say you have a double opt in mailing list, of which the subcriber list is store in the db. Im still somewhat of a newb, so bear with me... are there any pros/cons as to keeping the...
112
by: Andy | last post by:
Hi All! We are doing new development for SQL Server 2000 and also moving from SQL 7.0 to SQL Server 2000. What are cons and pros for using IDENTITY property as PK in SQL SERVER 2000? Please,...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
5
by: Fred | last post by:
Not much expertise on XSLT and trying to understand it's uses when creating apps in VS.NET? If I wanted flexibility on the UI (View aspect of M.V.C.): - How does it compare with creating...
2
by: scott | last post by:
Hi, Just wondering what sort of problems and advantages people have found using stored procedures. I have an app developed in VB6 & VB.NET and our developers are starting to re-write some of the...
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
10
by: Steve | last post by:
I need to build a very dynamic client and would be interested in knowing the pros and cons of using JSF and Ajax to accomplish this. Thanks. Steve
3
by: Andrea | last post by:
Hello everyone, I'd like to know which are the main pros and cons of using XML implementation in business organizations. >From a technical perspective, I find XML powerful, but looks like it is...
42
by: kenneth.m.mcdonald | last post by:
First, I don't intend this to be a flame war, please. Python and Ruby are the only two languages I'd willingly work in (at least amongst common languages), and TurboGears and Rails seem roughly...
0
by: Scott Abel | last post by:
The Fall 2007 CM Pros Summit Team is pleased to announce a Call for Participation. This year's Fall Summit will take place at the Westin Copley Place, Monday, November 26, 2007 in conjunction with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.