Thread: what is the type of op1 in Equality<Derived> const& op1 ?

  1. #1
    Registered User
    Join Date
    Jul 2016
    Posts
    1

    what is the type of op1 in Equality<Derived> const& op1 ?

    Equality<Derived> const& op1

    what is the type of op1 in above variable

  2. #2
    Guest
    Guest
    You mean spelled out in English? Because the type is right there in front of you. Reference to const Equality<Derived>.

  3. #3
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    It's funny, I spent a couple years programming in C and C++ before I learned that you could put the const to the right of the type :P

    Also, keep in mind that template classes aren't actually fully realized until your provide the template parameter.

    Like,
    Code:
    template <typename T>
    class my_class
    {
    
    };
    isn't actually a real type until you do:
    Code:
    my_class<int>
    Templates are neat because you can think of them as giving the compiler information to someday create a type.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by MutantJohn View Post
    Also, keep in mind that template classes aren't actually fully realized until your provide the template parameter.

    Like,

    isn't actually a real type until you do:
    Oh no, it's a type alright. A different one:

    Code:
    template<typename T> class foo {};
    template<typename T> void bar1(T) {}
    template<template<typename> class T> void bar2(T) {}
    
    bar1<foo>(); // Error
    bar1<foo<int>>(); // OK
    bar2<foo>(); // OK
    bar2<foo<int>>(); // Error
    (I did not check for syntax errors.)
    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.

  5. #5
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Yeah, I'm not really familiar with nested templates....

    Trying to make sense of that code is interesting. You can also pass around the templated class definition...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. changing return type of derived function
    By mikel123 in forum C++ Programming
    Replies: 6
    Last Post: 01-14-2008, 02:14 PM
  2. Why Array is derived data type ?
    By forumuser in forum C Programming
    Replies: 2
    Last Post: 10-19-2007, 06:01 AM
  3. Replies: 6
    Last Post: 04-27-2006, 10:55 AM
  4. Converting type string to type const char*
    By rusty0412 in forum C++ Programming
    Replies: 1
    Last Post: 07-11-2003, 05:59 PM
  5. Troubles overriding a const in a derived class
    By sh0x in forum C++ Programming
    Replies: 5
    Last Post: 10-05-2001, 07:11 PM

Tags for this Thread