Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Write a simple source code
Index -> Programming, C++ -> C++ Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
S_Grimm




PostPosted: Fri Aug 28, 2009 9:34 pm   Post subject: RE:Write a simple source code

I agree with bbi5291. If it compiles and runs under a C++ compiler, it can be considered C++ code. Even if it uses outdated header files and code. But hey, im not judgemental.
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Fri Aug 28, 2009 10:52 pm   Post subject: RE:Write a simple source code

Come on now, arguing semantics has never gotten anyone anywhere.

If you're writing 90% inline assembly, I think we can all agree that, even if you consider that C++ code, it's definitely not idiomatic C++ code. Smile
saltpro15




PostPosted: Fri Aug 28, 2009 11:00 pm   Post subject: RE:Write a simple source code

wow, this topic has come a long way from outputting "C++ Programming is fun!" Laughing
wtd




PostPosted: Fri Aug 28, 2009 11:51 pm   Post subject: Re: Write a simple source code

Not quite the message the OP wanted, but it is idiomatic.

c++:
#include <iostream>
#include <string>

class Greeter
{
    private:
        std::string name;

    public:
        Greeter(std::string n);

        const std::string get_name();

        friend std::ostream& operator<<(std::ostream& out, const Greeter& g);
};

int main()
{
    std::cout << Greeter("C++") << std::endl;
}

Greeter::Greeter(std::string n) : name(n)
{
}

const std::string Greeter::get_name()
{
    return name;
}

std::ostream& operator(std::ostream& out, const Greeter& g)
{
    return out << "Hello " << g.get_name();
}
rdrake




PostPosted: Fri Aug 28, 2009 11:55 pm   Post subject: Re: Write a simple source code

wtd @ Fri Aug 28, 2009 11:51 pm wrote:
Not quite the message the OP wanted, but it is idiomatic.

c++:
#include <iostream>
#include <string>

class Greeter
{
    private:
        std::string name;

    public:
        Greeter(std::string n);

        const std::string get_name();

        friend std::ostream& operator<<(std::ostream& out, const Greeter& g);
};

int main()
{
    std::cout << Greeter("C++") << std::endl;
}

Greeter::Greeter(std::string n) : name(n)
{
}

const std::string Greeter::get_name()
{
    return name;
}

std::ostream& operator(std::ostream& out, const Greeter& g)
{
    return out << "Hello " << g.get_name();
}
Now you're talking. Glad to see somebody knows how to write real C++ Laughing.
bbi5291




PostPosted: Sat Aug 29, 2009 10:21 am   Post subject: Re: Write a simple source code

If that were real C++, then any sane C++ programmer would be using Java instead. But wait, that hasn't happened...
wtd




PostPosted: Sat Aug 29, 2009 10:45 am   Post subject: RE:Write a simple source code

It's showing you the power of using the << operator. And yes, that's real C++ code.
bbi5291




PostPosted: Sat Aug 29, 2009 10:52 am   Post subject: Re: Write a simple source code

Of course, I didn't mean to assert that it's fake C++ code. What I meant is that if C++ is expected to look like that for such a simple program, nobody would ever use it to write such a program.
Sponsor
Sponsor
Sponsor
sponsor
A.J




PostPosted: Sat Aug 29, 2009 11:50 am   Post subject: RE:Write a simple source code

Not here, not now.

This thread was merely used to answer jhooper3581's question. If you have anything else to discuss, do it elsewhere.

[No, I have every right to state my opinion. I am not suggesting that any action should be taken, just that I believe that they ought to take the conversation elsewhere.]
bbi5291




PostPosted: Mon Aug 31, 2009 9:24 am   Post subject: Re: Write a simple source code

Just for fun.
c++:

#include <iostream>
using namespace std;
template<char c,class T>
struct lol
{
        lol()
        {
                cout << c;
                T x;
        }
};
int main()
{
        lol<'C',
        lol<'+',
        lol<'+',
        lol<' ',
        lol<'p',
        lol<'r',
        lol<'o',
        lol<'g',
        lol<'r',
        lol<'a',
        lol<'m',
        lol<'m',
        lol<'i',
        lol<'n',
        lol<'g',
        lol<' ',
        lol<'i',
        lol<'s',
        lol<' ',
        lol<'f',
        lol<'u',
        lol<'n',
        lol<'!',
        lol<'\n',
        int> > > > > > > > > > > > > > > > > > > > > > > > LOL;
        return 0;
}
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 25 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: