Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
A

AkashAg

@AkashAg
About
Posts
11
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Interview question
    A AkashAg

    thanks Aescleal :)

    C / C++ / MFC question c++ graphics career

  • STL map and multimap implementation
    A AkashAg

    It will be very much appreciated if someone can throw some light on this.

    C / C++ / MFC question c++ data-structures

  • Interview question
    A AkashAg

    Hi All, I have been asked these question in a telephonic interview: 1) Why some header files have there definitions in itslef and don't have a '.cpp' for definition? Classic examples are vector.h and other STL files. What will be the impact of having definitions in a separate cpp file/ 2) What is the disadvantage if I make all my functions inline and inline request is always acknowledged by the compiler? I told him that recursion is not possible, load time will be more, page faults will be more, binary size will increase. But he was looking for some other things as well. It will be very much helpful if someone can fulfill these queries with explanatory notes. BR, Akash

    C / C++ / MFC question c++ graphics career

  • STL map and multimap implementation
    A AkashAg

    Hi All, I have some questions in mind about map and multimap. 1) I know that STL use height-balanced-binary-search tree for MAP implementation but what is actually used for multimap. 2) multimap can also use the same thing with a list in each node for a key. Am I right? 3) How do I give a iterator functionality in a tree structure as in maps and multimaps as in tree it's hard to go through data sequentially. It will be very helpful if these questions can be answered. BR, Akash

    C / C++ / MFC question c++ data-structures

  • Multimap (STL) equal_range function
    A AkashAg

    Hi, I have a doubt regarding multimap::equal_range function for the following program.

    int main ()
    {
    multimap<char,int> mymm;
    multimap<char,int>::iterator it,it1,it2;
    pair<multimap<char,int>::iterator,multimap<char,int>::iterator> ret;

    mymm.insert(std::pair<const char,int>('a',10));
    mymm.insert(std::pair<const char,int>('b',20));
    mymm.insert(std::pair<const char,int>('b',30));
    mymm.insert(std::pair<const char,int>('c',40));
    mymm.insert(std::pair<const char,int>('b',50));
    mymm.insert(std::pair<const char,int>('c',60));
    mymm.insert(std::pair<const char,int>('d',70));

    cout << "mymm contains:\n";
    for (char ch='a'; ch<='d'; ch++)
    {
    cout << ch << " =>";
    ret = mymm.equal_range(ch);
    it1 = ret.first;
    it2 = ret.second;
    cout << (*it1).second << " " << (*it2).second << endl;
    for (it=ret.first; it!=ret.second; ++it)
    cout << " " << (*it).second;
    cout << endl;
    }

    return 0;
    }

    It is giving following output:

    mymm contains:
    a =>10 20
    10
    b =>20 40
    20 30 50
    c =>40 70
    40 60
    d =>70 70

    What I am not getting is the o/p for 'b'. I think it should be

    b =>20 60
    20 30 50

    Please revert. BR, Akash

    C / C++ / MFC c++

  • How does this template work
    A AkashAg

    I tried this and it worked find. But I am still confusing why it is working. What are the scenarios in which this thing will work. Does it mean that U can access methods from NULL pointer but not attribute?

    C / C++ / MFC

  • How does this template work
    A AkashAg

    class A
    {
    int i;
    public:
    void func1() {cout << "func1" << endl;};
    static void func2() {cout << "func2" << endl;};
    void func3() {i =1; cout << "func3" << endl;};
    };

    template <class T> class Smart
    {
    private :
    T *m_ptr;
    public :
    explicit Smart(T *p = 0) : m_ptr(p) {}
    T& operator*() {return *m_ptr;}
    T* operator->() {return m_ptr;}
    ~Smart() {delete m_ptr;}
    };

    int main()
    {
    Smart<A> s(0);
    (*s).func1();

    system("PAUSE");
    }

    On running it I saw that it prints "func1" but how it it possible. I initialize it as NULL.

    C / C++ / MFC

  • Storage for Statis Data members
    A AkashAg

    Hi, Thanks for your answer. Between, I assume that by 'fixed program memory', you mean heap. Isn't it? Secondly, at what time storage for them is reserved? Rgrds, Akash

    C / C++ / MFC question

  • Storage for Statis Data members
    A AkashAg

    Hi All, I want to know that when & where does the storage for static data members of a class is defined and what is it's life time. Since we don't need to create an object for assessing static members, does the storage is defined only by defining a class with static data members. Please let me know about the same ASAP. Thanks, Akash

    C / C++ / MFC question

  • Return value from a funtion
    A AkashAg

    yaa, true... But if I've already checked for error conditions and all. does it matter...

    C / C++ / MFC help question

  • Return value from a funtion
    A AkashAg

    Hi, I want to know the side effects if I don't save the value returned from a function call. ex:

    int foo()
    {
    return (10);
    }

    main()
    {
    foo();
    }

    Doubts: 1. Does this type of code may cause some warnings or other issues? 2. Is it an optimized approach or do I need to save the value returned by foo()? Thanks for ur help. Akash

    C / C++ / MFC help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups