473,395 Members | 1,666 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,395 software developers and data experts.

Doubts related to C/C++

Hi All,

Could anybody answer for the following queries?

1) How addition/subtraction of two different objects is possible in C without operator overloading? Here "int" and "float" could be taken as two different objects. (Not sure whether my understanding is correct)

2) I have given a simple structure which is used to construct a linked list.
struct a
{
char b[4];
struct a *next;
};
My question is why "*next" should be of the same type ie "struct a". Cannot we use "INT *NEXT" as a->next is just a address?

3) class sample
{
public:
int a, b;
sample()
{
a = 5;
b = 10;
}
}

main()
{
sample s, s1;
s1 = s;
}
When I say "s1 = s" only "variable a" should get copied to object "s1". How can I achieve this?

Thanks & Regards
Sathish Kumar
Jun 5 '10 #1
1 1259
weaknessforcats
9,208 Expert Mod 8TB
You have to write a function in C to copy one object to another.

Expand|Select|Wrap|Line Numbers
  1. void Copy(struct Data* left, struct Data* right)
  2. {
  3.     /*copy right object to left object here. */
  4. }
Actually, you have to do the same thing in C++ but there is syntax that let's you make the call this way:

Expand|Select|Wrap|Line Numbers
  1. objA = objB;
rather than:

Expand|Select|Wrap|Line Numbers
  1. Copy(&objA, &objB);
Jun 5 '10 #2

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

Similar topics

0
by: abbas reji | last post by:
--0-599929911-1059996886=:4358 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-Id: Content-Disposition: inline ...
3
by: Ameya | last post by:
hello, i have a very specific doubt related to file handling. My objective is to make some modifications in the output data file of one software which would be the input data file for another...
6
by: ritesh | last post by:
Hi, I have been reading some text on C and C++ (i.e advanced books). One of the books mentioned that C++ requires a runtime support whereas C does not - what the author was trying to say was...
6
by: Rajorshi Biswas | last post by:
Hi folks, Suppose I have a large (1 GB) text file which I want to read in reverse. The number of characters I want to read at a time is insignificant. I'm confused as to how best to do it. Upon...
1
by: NagaKiran | last post by:
Hi I want to post VBA related doubts. Where can I post my doubts in VBA? thanks bye
1
by: archana | last post by:
hi all I have some doubts related to database handling in .net. I am using sqldataadapter to update and insert rows into database. What i want to know is at a time of inserting rows using...
1
by: archana | last post by:
Hi all, I want to clear one doubt which i am facing regarding timer. Suppose i have one timer in which i am generating some files. and interval of my timer is say 5 min. Say suppose at...
0
by: archana | last post by:
Hi all, I have some confusion related to threading and autoresetevent. I have 5 threads running for each i have autoresetevent which i am setting through thread procedure. On each of event...
7
by: ravips | last post by:
I have a map<char *,int it does not work consistently. I have used similar sort of implementation as below: map<char *,intm1; map<char *,int>::iterator i; m1 = 31; m1 = 28; m1 = 31; m1 =...
4
by: somenath | last post by:
Hi all, Can any one let me know what will be the out put of the bellow mentioned program and why it is so . typedef struct { int day; int month; int year; } MYDATE;
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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
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...

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.