Thread: Variables | Pointers in arguments really needed?

  1. #31
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by medievalelks View Post
    I don't disagree with either reply, just hoping that the OP realizes the importance of profiling to find real bottlenecks, and that they're usually tied to the design, algorithms, etc.
    And with that, I fully agree too.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #32
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Teaching new programmers to do the little things early is never a bad idea.

  3. #33
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    Quote Originally Posted by bobbelPoP View Post
    Code:
    
          class Database {
     public:
     std::string Query;
     void SendQuery(std::string,&Database); // Would this be faster?
     //Reminds me of like a wildcard variable/pointer/reference thing
    
     // or
    
     void SendQuery( std::string Query, Database& db ); // or would this be faster?
    
    }
    there is no reason that a class database should require a reference to an instance of database to execute a query.

    if you need to execute a query on an external database, just execute the query off that instance. inside the query implementation it should always refer to this
    Last edited by m37h0d; 08-04-2008 at 08:55 AM.

  4. #34
    Registered User
    Join Date
    May 2008
    Posts
    141
    Quote Originally Posted by rags_to_riches View Post
    Teaching new programmers to do the little things early is never a bad idea.
    I'm not new at programming, I'm new at C/C++. I have past experience with java and php. :P

  5. #35
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by bobbelPoP View Post
    I'm not new at programming, I'm new at C/C++. I have past experience with java and php. :P
    In this context, you are a new C++ programmer, and it still means that understanding when and where to use const reference to avoid copying is a good thing to learn NOW, rather than later.

    Note that objects that are less than or equal to twice the size of a pointer should be passed as copies (so no const reference there), as there would be no benefit to pass a pointer (reference) to those objects.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #36
    Registered User
    Join Date
    May 2008
    Posts
    141
    Well I'd like to create something that I originally wanted to create first, even if it has a few bugs. It doesn't mean I'm going to release it, just means I want to do what I originally planned to do with the language. xD

    I wanteed to create:
    a game ( 2d shooter ),
    a web browser,
    and an os ( far from my league atm )

  7. #37
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I would say they're all far from your current skill. All complex programs.
    Although that doesn't mean you can't achieve something in the future.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #38
    Registered User
    Join Date
    May 2008
    Posts
    141
    Quote Originally Posted by Elysia View Post
    I would say they're all far from your current skill. All complex programs.
    Although that doesn't mean you can't achieve something in the future.
    Well I know the concepts of creating them, and I know some code that will actually make it work, but the problem is, how to assemble it correctly. I just need to feel more comfortable about C/C++ and learn more about it.


    By the way, I have a book called absolute C++, will that help me. And one more thing, how long will it take me to fully learn C/C++

  9. #39
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by bobbelPoP View Post
    a game ( 2d shooter ),
    This is probably doable.
    a web browser,
    That's a HUGE task if you want to do all that a normal browser does with JavaScript and other extensions.
    and an os ( far from my league atm )
    On some levels this is probably easier than a web-browser, because you need a lot less of your own OS to actually do something useful - but if you are after something that can read disks, talk to the internet and display 3D graphics [using a modern graphics card], you are in for a big task f'sure.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #40
    Registered User
    Join Date
    May 2008
    Posts
    141
    I have worked with the functions ( WINAPI ( MSDN ) ) in DX & Windows, I know how to import textures, and I've made polies on 2d space and such. So..

  11. #41
    Registered User
    Join Date
    May 2008
    Posts
    141
    By the way, I forgot, a database software was one of the things I wanted to create. :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. write functions with pointers variables
    By noob programmer in forum C Programming
    Replies: 5
    Last Post: 10-25-2008, 05:48 AM
  2. Function Pointers and Arguments
    By mike_g in forum C Programming
    Replies: 2
    Last Post: 04-08-2008, 04:39 AM
  3. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 10:56 AM
  4. pointers and variables
    By dharh in forum C Programming
    Replies: 4
    Last Post: 02-05-2002, 12:53 PM
  5. Using pointers - asterisks needed ?
    By Nutshell in forum C Programming
    Replies: 5
    Last Post: 01-28-2002, 06:56 PM