#define's Profile User Rating: *****

Reputation: 1329 Grandmaster
Active Posts:
4,555 (2.26 per day)
19-February 09
Profile Views:
Last Active:
User is offline Aug 25 2014 04:56 AM

Previous Fields

Who Cares
OS Preference:
Favorite Browser:
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Your Car:
Dream Kudos:
Expert In:

Latest Visitors

Icon   #define has not set their status

Posts I've Made

  1. In Topic: unordered_map is behaving differently from expected.

    Posted 24 Aug 2014

    Hi, this suddenly jumped out at me :-

    03	if (!containsSymbol(symbol)); //<- semicolon
    04		initializePurchaseRecords(symbol);

  2. In Topic: how to declare iterator ?

    Posted 22 Aug 2014

    Hi, making a simpler version :

    #include <iostream>
    #include <string>
    #include <vector>
    using namespace std;
    template< template<class, class> class ContainerType, class DataType>
    class Movie 
        string m_title;
        ContainerType<DataType, std::allocator<DataType> > Actors;
        typedef typename ContainerType<DataType, std::allocator<DataType> >::iterator iterator;
        Movie(const string title) {m_title = title;}
        void push_back(const DataType &data) {Actors.push_back(data);}
        void show()
          iterator it;
          cout << m_title << " :-" << endl;
          for( it = Actors.begin(); it != Actors.end(); it++)
            cout << *it << endl;
    int main()
      Movie<vector, string> movie("The Maltese Falcon");
      movie.push_back("Humphrey Bogart");
      movie.push_back("Mary Astor");
      movie.push_back("Peter Lorre");
      movie.push_back("Sydney Greenstreet");

    The actor's list could be another class.
  3. In Topic: Snake Game code in c

    Posted 22 Aug 2014

    Hi, it is better to try keep functions simple and do what they say - so wait in show can be removed to main.

    I think you are saying that the frame is not synchronised with the screen. You are printing 22 rows. If the screen is 25 rows you can add some newlines to the show function.

    #define SCREEN_Y 25
    // this function shows the base 
    //   so can call it showbase
    void showbase()
         int y, x;
         printf ("\n\tScore: %d", score);
         printf ("\n");
         for (y = 0; y < MAX_Y ; y++) {
             printf ("\t");
             for (x = 0; x < MAX_X; x++) {
                 printf ("%c", base[y][x]);
             printf ("\n");
         // synchronise with the size of screen
         for( ; y < SCREEN_Y; y++ ) 
         // move to main
  4. In Topic: #define statements in a header file.

    Posted 21 Aug 2014

    Hi, welcome to DIC.

    View Postdudeperfect, on 21 August 2014 - 01:08 PM, said:

    My question would be about that #define DOUBLENUM_H . I heard that it is called header guard, it prevents program to include two same headers twice?

    Yes, that is the intention. It doesn't stop the file being opened again, the statements (directives) stop the code contained within being compiled twice.


    But what is actually that DOUBLENUM_H ? Does it means anything outside that header file? Or it is just used locally to determine whether this header was defined before?

    It is called a macro, when you define DOUBLENUM_H you define that name outside of the file in the compiler preprocessor. If the macro has been defined, the ifndef .. endif directive will stop the file being compiled again, avoiding errors.


    Another question would be about that #include "stdafx.h" statement.
    It is included inside Main.cpp and also inside DoubleNumber.cpp .

    The stdafx.h is a Microsoft file related to precompiling, I believe. Other compilers do precompiling without using a file such as this. Precompiling can be switched off in Microsoft.


    Why is this is not using a header guard? I checked out the content of this header file and it has this:

    #pragma once
    #include "targetver.h"
    #include <stdio.h>
    #include <tchar.h>


    no define statements.

    The directive #pragma once does the same job as the header guards, but in a slightly different way. The compiler remembers which file has been already opened, with header guards the file has to be opened again. A few compilers use #pragma once but it is non-standard.

    pragma once


    Is (it), that (it) means that program can include same header several times, but can't do the same thing with function declarations?

    You can get an errors if functions etc are already declared. You may have several header files in a program, some of which may include the same lower-level header file.

    C preprocessor
  5. In Topic: Oracle OTT utility to create C++ objects on windows

    Posted 19 Aug 2014

    Hi, try it without the slash and password.

    Without a password the system should prompt for one.

    Maybe try a different case for test.

My Information

Member Title:
Duke of Err
Age Unknown
Birthday Unknown
Delta Quadrant
Years Programming:
Programming Languages:

Contact Information

Website URL:
Website URL  http://


Page 1 of 1
  1. Photo

    GryphonClaws Icon

    10 Jan 2013 - 01:15
    Thanks #define. I can't believe I missed such a simple detail.
  2. Photo

    raghav.naganathan Icon

    07 Nov 2012 - 20:40
    Dude...before your reputation changes, I would like to tell you that it(729) is a perfect cube :) Cheers :)
Page 1 of 1