473,326 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

"typedef typename" inside template

Hi!

I have a question for u guys!
I would like to use the c++ package ITK (www.itk.org) for internal handling och data and functions in a dataset3D class of mine!

I also want to use a base class to be able to use all kinds of datasets (2D/3D/4D...)
-----------------------------------------------------------
class dataset_base{
public:
virtual void printDataInfo()=0;
DATASET_TYPE type;
string file_path;
};
-----------------------------------------------------------

But I need some help with the template part of my dataset class....
Today my class looks like this...

------------------dataset3D.h-----------------------------------------
#ifndef _dataset3D_h_
#define _dataset3D_h_
#pragma once

#include <string>
#include <stdio.h>
#include <iostream>
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "dataset_base.h"
using namespace std;

template<class T>
class dataset3D: public dataset_base{
public:
typedef itk::Image<T,3> ImageType;
typedef typename ImageType::Pointer ImagePointerType;
typename int a;

dataset3D2(string filepath);
void printDataInfo();

private:
ImagePointerType theImage;

// int loadVolumeFromFile(string file);
ImagePointerType loadVolumeFromFile(string file);
};

#include "dataset3D2.cpp"
#endif

------------------dataset3D.cpp-----------------------------------------

//template<class T> int dataset3D2<T>::loadVolumeFromFile(string file){

template<class T> dataset3D2<T>::ImagePointerType dataset3D2<T>::loadVolumeFromFile(string file){ //(***)
cout<<"load_v("<<file<<")"<<endl;
}
return image.GetPointer();
}

-----------------------------------------------------------
But this gives following Compiler error in visual 7.1...
pointing at row (***)

Compiling...
dataset_array.cpp
c:\Joel\Code\ITKVTK\matrix\Src\Main\dataset3D2.cpp (28) : warning C4346: 'dataset3D2<T>::ImagePointerType' : dependent name is not a type
prefix with 'typename' to indicate a type
.....
.....

What is it that I am doing wrong!
I thought that (typedef typename was enough...)
Thanks in advance...

// Joel
Sep 23 '05 #1
1 18938
Hey
It's been a long time since you posted this, but just in case you were wondering:

where you use
typedef typename ImageType::Pointer ImagePointerType;
(or any type name combination)
to use it as a return type for a function, you would need to specify that this is a typename, or in your example
template<class T>
typename dataset3D2<T>::ImagePointerType
dataset3D2<T>::loadVolumeFromFile(string file){ //(***)
etc. etc.
Notice the placement of the "typename" before the actual typenamed name
Mar 29 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Michael Olea | last post by:
Here is a design problem I ran into this am - and I have cleaned the bathroom, scrubbed toilet sink and tub, windexed all glass, mopped the floor, and vacuumed the house - no dice, the problem is...
3
by: Generic Usenet Account | last post by:
This is a two-part question. (1) I have implemented a "Datastructure Registry" template class. I am getting no compiler warnings with older compilers, but newer compilers are generating the...
0
by: Gary | last post by:
Hi, there, I am going to use a command line parser class, which works well in VC6.0, in VC++7.1. However error message such as "C2059: syntax error :')'", and "C2061: syntax error : identifier...
4
by: Sacha | last post by:
I'm aware, that up to date, "typedef templates" are not defined within the C++ standard. The seemingly common workaround is this: template <class T> struct MyTypeDef { /* ultimately I need...
0
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never...
3
by: IR | last post by:
Hi, I've been trying to do the following (which doesn't compile) : template<class T, class F = Example<T struct Example { F foo(); };
8
by: Mohammad Omer Nasir | last post by:
Hi, i made a structure in header file "commonstructs.h" is: typedef struct A { int i; A( ) {
8
by: cman | last post by:
What does this kind of typedef accomplish? typedef struct { unsigned long pte_low; } pte_t; typedef struct { unsigned long pgd; } pgd_t; typedef struct { unsigned long pgprot; } pgprot_t I am...
4
by: msukumarbabu | last post by:
Hi all, What will be difference between "typedef enum" and "enum". or difference between “typedef structure" and "structure" I am going through some code. in that some place they are using...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.