• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

D

Returning Templates

5 posts in this topic

Heya, I''m having a serious problem here, I try to return a template class from a function and it all goes to hell. Basically I am trying to do this:
TArray& ListFiles( /* blah */ );
or this:
int ListFiles( TArray* /* blah */ );
 
and none of them return the Array Object properly. I.e. its all fuX0rd... I''m using MSVC 6.0 BTW and so I am wondering if this is a compiler bug, template bug, or that I have to do something special (like make a good Copy constructor?). -Cheers. P.S. I''ve already got ideas to make a wrapper class for TArray and my string class works okay.
0

Share this post


Link to post
Share on other sites
The problem is with your code; it''s not a compiler bug.

Try something like this:


template
TArray& ListFiles(/* blah */) {...}

// Or...

template
int ListFiles(TArray *t, /* blah */);

// Note: you may have to call your function like this:
// TArray t = ListFiles(/* blah */);


Hope this helps.
0

Share this post


Link to post
Share on other sites
Sorry.... Let''s try this again, shall we?

template < typename T >
TArray< T >& ListFiles(/* blah */) {...}

// Or...

template < typename T >
int ListFiles(TArray< T > *t, /* blah */);

// Note: you may have to call your function like this:
// TArray< int > t = ListFiles< int >(/* blah */);
0

Share this post


Link to post
Share on other sites
Well the thing is that TArray, and BString are already defined classes, and that particular function is defined within another class.
i.e.

template class TArray { ... };
// and
class BString { ... };
// etc


Strickly speaking

TArray&

is just the return type.

And the way that I''m calling it is like so:


TArray Stuff = Something.ListFiles(/* blah */);


It still stuffs up then, so I am really wondering if its got anything to do with the = operator. Its just wierd...
0

Share this post


Link to post
Share on other sites
It appears your templates got cut off (because this board seems to interpret angular brackets as HTML tags).

Anyway, you can''t do something like this:

TArray t = ...;

You have to give TArray a type. So it''d be like this:

  
TArray<int> t = Something.ListFiles(/* blah */);


You have to specify a type for the template class when you call it.

Also, if the return type is "TArray&" (and not "TArray< T >&"), and TArray is a template then that code is probably wrong. It needs to look like:

template< typename T >
TArray< T >& Something::ListFiles(/* blah */) { ... }
0

Share this post


Link to post
Share on other sites
Yeah it got cut off, basically I have done everything that you have suggested it before, (I''m not that much of an idiot you know).

Oh well I''ll just make a wrapper class or something.
0

Share this post


Link to post
Share on other sites