473,498 Members | 1,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Templates - Garbage In Garbage Not Out

All,

In a .h file, I am declaring/defining a template as

template<class T> class MyClass
{
public:
void test()
{
haskdfhsjfksfhkfskfsfkklkll89829482498020
gdgk;ek;kd;gkdkd;gdkg;d
}
};

and for some reason, it is compiling fine, even with the 'garbage' in
the function body. Somehow it doesn't see my logic in the body of the
function in compile time. Why? Any help? I am using CC 5.3 (Forte
Developer 6.0 under Solaris 8).

Thanks!

-RB

Jul 25 '05 #1
1 1139
Since your class is templatized, only a first-pass parse is performed.
The first-pass is simply a syntactic check, not a semantic one. Since
your "garbage" line technically consists of well-formed syntactic
tokens, the compiler doesn't complain.

If, however, you try to instantiate MyClass (ie: MyClass<SomeClass> t;
), the compiler will complain. This happens because when MyClass is
instantiated with a particular class T, the compiler *will*
semantically process the tokens in test().

--Steve

Jul 25 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2514
by: Tom Alsberg | last post by:
Hi there... I'm recently trying to get a bit acquainted with XML Schemas and XSL. Now, I have a few questions about XSL stylesheets and templates: * Is there a way to "enter" a child element...
22
2142
by: E. Robert Tisdale | last post by:
According to the C++ FAQ Lite: http://www.parashift.com/ What is "genericity"? Yet another way to say, "class templates." Not to be confused with "generality" (which just means avoiding...
6
1291
by: Mike | last post by:
Hey! I've started to use templates for storing arrays of doubles. The template itself will then be passed on to a linked-list. My problem is that Im not 100% familiar with how templates are...
5
1874
by: Andreas Micheler | last post by:
Hi, I have several long complex C macros in the math module of aUCBLogo like #define _XFUNC_primitive(NAME)\ NodeP _##NAME(PairPP arg)\ { ((ObjectP)(arg))->var()->NAME( arg );\ return...
8
1292
by: collection60 | last post by:
Hi people, I want to use templates, for syntatic niceness only, not for doing similar operations on different types. The types I'm manipulating are basically just pointers. So if it's a pointer...
28
2592
by: NewToCPP | last post by:
Hi, I am just trying to find out if there is any strong reason for not using Templates. When we use Templates it is going to replicate the code for different data types, thus increasing the...
8
3760
by: mscava | last post by:
I've created CoutedPtr<Ttype to be able o track how many times pointer is being reference( for garbage collecting ). The problem is that the polymorphism doesn't work. e.g. CountedPtr<Bitmap!=...
4
1776
by: mscava | last post by:
I'm building DataManager<T>. A class where shared data will be stored. One of things useful to implement is garbage collection. But it still gives me this error: stl_algo.h:1076: error:...
158
7685
by: pushpakulkar | last post by:
Hi all, Is garbage collection possible in C++. It doesn't come as part of language support. Is there any specific reason for the same due to the way the language is designed. Or it is...
0
7124
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6998
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5460
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.