473,508 Members | 2,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you type test in C++... Newb question :)

Hello all.... 1st post here

I was hoping someone could tell me how you test the datatype of a
variable in C++?
Like if I declare

struct ELEMENT{int key;} variable1;

OR

int variable2 = 10;

How can I type check variable1 or variable2?

I mostly write in Python... I'm looking for something similar to
python's way to do it... if there is in C++
type(variable1) #would return the datatype of variable1
or
isinstance(variable2, int) #would return true is variable2 is a
instance of the int class

Thanks in advance,
Chris

Nov 3 '05 #1
2 2247
Irish wrote:
Hello all.... 1st post here
Did you read the Welcome message? Did you read the FAQ? If you didn't,
please do. It is very important you have all the necessary information
about this newsgroup so we don't have to repeat ourselves.
I was hoping someone could tell me how you test the datatype of a
variable in C++?
Like if I declare

struct ELEMENT{int key;} variable1;

OR

int variable2 = 10;

How can I type check variable1 or variable2?
What do you mean? And what is it for?
I mostly write in Python... I'm looking for something similar to
python's way to do it... if there is in C++
type(variable1) #would return the datatype of variable1
or
isinstance(variable2, int) #would return true is variable2 is a
instance of the int class


No such thing exists in C++. What problem are you trying to solve by
using that approach? I am fairly certain there are other ways to solve
your problem.

V
Nov 3 '05 #2
Thanks for the info Victor. I found a fix for my problem :)

Nov 3 '05 #3

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

Similar topics

0
1633
by: David E. | last post by:
So as a programmer, what's the best thing to study? EJB? How much of the J2EE or Enterprise architecture is necessary to no? I guess I need a good overview for a newb like me... thanks.. --...
1
1542
by: notbob | last post by:
Newb here! Using 4.0.20 on Slack. Slogging through the official manual. At 2.4.3 Securing the Initial MySQL Accounts, I'm finally stopped cold while trying to follow instructions. Here's what I...
4
1429
by: Donald Newcomb | last post by:
I'm a real Python NEWB and am intrigued by some of Python's features, so I'm starting to write code to do some things to see how it works. So far I really like the lists and dictionaries since I...
6
1669
by: Sean Berry | last post by:
Hello all I have build a list that contains data in the form below -- simplified for question -- myList = ,, ...] I have a function which takes value3 from the lists above and returns...
11
1970
by: The_Kingpin | last post by:
Hi all, I'm new to C programming and looking for some help. I have a homework project to do and could use every tips, advises, code sample and references I can get. Here's what I need to do....
2
1174
by: Benign Vanilla | last post by:
I created a web site in ASP that is heavily data driven. On the home page, http://iheartmypond.com/. The list of categories is gathered from the database. I grab the distinct top level categories,...
4
4216
by: sklett | last post by:
I'm revisiting an old series of overloaded methods I have and I would like to convert them to a single generic method. Here is the method in it's current, overloaded implementation: <code>...
6
1630
by: cppnow | last post by:
Hello. I have a strange conceptual problem I'm trying to think about. I would like to build a library that allows the user to do the following: 1) User defined types: The user defines their...
5
1445
by: Fredo | last post by:
I'm new to Generics (years and years of VS.NET 2003 development, but very little .NET 2.0+). I have some routines for conversion from RGB to different color spaces and back. I would like the...
0
7224
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
7120
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
7323
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
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7494
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
5626
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
5050
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...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
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.