Like Tree6Likes

Convert Java To C++

This is a discussion on Convert Java To C++ within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by laserlight at least until you become a Roman citizen and can get away with acting like you ...

  1. #31
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    Quote Originally Posted by laserlight View Post
    at least until you become a Roman citizen and can get away with acting like you are Greek (with all due respect to GReaper ).
    Well , in Sparta ( a.k.a Sparti ) they would have probably thrown him out!
    Devoted my life to programming...

  2. #32
    Registered User gardhr's Avatar
    Join Date
    Apr 2011
    Posts
    151
    Quote Originally Posted by whiteflags View Post
    Not defining main means that main is not invoked and if main is never defined the program cannot link. Further if you do this instead of that the logical conclusion is that never happens. So you did trap yourself.
    All of this hair-splitting is unnecessary though, really - everyone here should have known what I meant from the very beginning. Instead, some chose to sift through my words like a pack of lawyers, for no other reason than to claim some hollow victory of semantics.

    Touche!

    Anyone may do as they are so enclined insofar as using either a main function directly or else by way of some class. Both surely have their own merits and disadvantages, but neither is "wrong", "incorrect", or "bad style". It's all just a matter of preference.

  3. #33
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by gardhr View Post
    All of this hair-splitting is unnecessary though,
    It's not hair splitting. I said "main is not part of a class" and you said "depends".

    No, it doesn't depend. It's not part of a class. It's the entry point to every C++ program. That's all. There are no split hairs. It is always there. It's not part of a class. Period.

    You didn't say "I make a class that I call from main and have it be the starting point for the remainder of my program."
    Quote Originally Posted by gardhr View Post
    really - everyone here should have known what I meant from the very beginning. Instead, some chose to sift through my words like a pack of lawyers, for no other reason than to claim some hollow victory of semantics.
    I didn't sift through your words. I took the first thing you said in reply to the first thing I said, and the first thing you said was wrong. Period.
    Quote Originally Posted by gardhr View Post
    main function directly or by way of some class. Both surely have their own merits and disadvantages, but neither is "wrong", "incorrect", or "bad style". It's all just a matter of preference.
    WRONG. There is no main "by way of some class".


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #34
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,794
    Quote Originally Posted by gardhr
    All of this hair-splitting is unnecessary though, really - everyone here should have known what I meant from the very beginning. Instead, some chose to sift through my words like a pack of lawyers, for no other reason than to claim some hollow victory of semantics.
    I can see where you are coming from, but consider GReaper's confusion expressed in post #9 that required clarifications from various people, including yourself. To be fair, quzah's statement was inaccurate too: a function named main can indeed be a member of a class; but the global main function cannot be a member of a class.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #35
    Registered User gardhr's Avatar
    Join Date
    Apr 2011
    Posts
    151
    Quote Originally Posted by laserlight View Post
    You are proposing that your unusual and unnecessary method of doing things be adopted? How absurd!

    Sure, it may be more akin to what ForeverAndOne is used to in Java, and maybe GReaper likewise finds it familiar, but when in Rome, do as the Romans do... at least until you become a Roman citizen and can get away with acting like you are Greek (with all due respect to GReaper ).
    Your method might force the user to declare command line arguments and environment variables (not to mention a useless integer) to be passed along to the object. Mine does not. I have merely simplified a needlessly redundant artifice of C++ programming. How could that possibly be labeled "unnecessary"?

    If "acting like a Greek" means being creative and open-minded, sure, I'll go with that. I don't prescribe to anything more than safe, intelligent coding practices. It that's a crime (and in Rome, everything seems to be), so be it. As they say, "I'll follow the Sun".

  6. #36
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by laserlight View Post
    To be fair, quzah's statement was inaccurate too: a function named main can indeed be a member of a class; but the global main function cannot be a member of a class.
    I should have been more precise. The entry point to your program is not part of a class as it is in Java.


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #37
    Registered User gardhr's Avatar
    Join Date
    Apr 2011
    Posts
    151
    Quote Originally Posted by laserlight View Post
    I can see where you are coming from, but consider GReaper's confusion expressed in post #9 that required clarifications from various people, including yourself. To be fair, quzah's statement was inaccurate too: a function named main can indeed be a member of a class; but the global main function cannot be a member of a class.
    This may have been to the root of the confusion, I suppose. I was referring to the fact that my class defines it's own main function, while the real 'main' is invoked implicitly from within a header file. I thought I was being clear. Perhaps not.

  8. #38
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,794
    Quote Originally Posted by gardhr
    Your method might force the user to declare command line arguments and environment variables (not to mention a useless integer) to be passed along to the object. Mine does not.
    That isn't actually an advantage, and there would not necessarily be a "useless integer" passed with what I stated as more common in post #10.

    Quote Originally Posted by gardhr
    I have merely simplified a needlessly redundant artifice of C++ programming. How could that possibly be labeled "unnecessary"?
    I don't see how it is "a needlessly redundant artifice" to begin with.

    Quote Originally Posted by gardhr
    This may have been to the root of the confusion, I suppose. I was referring to the fact that my class defines it's own main function, while the real 'main' is invoked implicitly from within a header file. I thought I was being clear. Perhaps not.
    You did not state the details earlier, so that was not clear, though I understood that you were not saying that there would not be a global main function at all. However, to someone with less knowledge of C++, it would and did seem that you were saying that there would not be a global main function. That's unfortunate, but having been clarified, so be it.

    Quote Originally Posted by gardhr
    the real 'main' is invoked implicitly from within a header file.
    What exactly do you mean by this? I understand it to mean that you define the main function in a header file that is included in exactly one source file.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #39
    Registered User gardhr's Avatar
    Join Date
    Apr 2011
    Posts
    151
    Quote Originally Posted by laserlight View Post
    You did not state the details earlier, so that was not clear, though I understood that you were not saying that there would not be a global main function at all. However, to someone with less knowledge of C++, it would and did seem that you were saying that there would not be a global main function. That's unfortunate, but having been clarified, so be it.
    Agreed.

    Quote Originally Posted by laserlight View Post
    What exactly do you mean by this? I understand it to mean that you define the main function in a header file that is included in exactly one source file.
    Correct. From the header file, 'main' invokes a virtual function on a singleton pointer to the program's sub-base-class which then propagates the parameters to the actual (CRTP) base class, which is customizable via a 'traits' parameter (optionally) specified by the final derived class (to control the underlying container types to be used, etc; in case you want to use a map-type interface for the environment variables or what have you).

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. java to c.
    By radxxx in forum C Programming
    Replies: 3
    Last Post: 04-11-2009, 08:56 AM
  2. Multiple Java files for one Java project
    By doubleanti in forum Windows Programming
    Replies: 2
    Last Post: 11-22-2004, 01:06 AM
  3. How to use Java with C++
    By Arrow Mk 84 in forum C++ Programming
    Replies: 2
    Last Post: 02-27-2003, 03:12 PM
  4. I use Java but...
    By zurdo1119 in forum C Programming
    Replies: 4
    Last Post: 08-04-2002, 02:05 PM
  5. C# vs. JAVA
    By talal*c in forum C# Programming
    Replies: 10
    Last Post: 04-06-2002, 02:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21