cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Passing a struct to function
Passing a struct to function
Mar 29, 2013 at 3:20pm UTC
venkatacplpl
(113)
if we want to pass an object to function we pass it as
returntype func(student s) //student is class and s is an object
and if i define a structure called student and want to pass one instance of it
to function then it shoould be written as
returntype func(struct student s) mentioning struct explicitly.
why cant i write it as
returntype func(student s) like i do with calsses and objects??
is it allowed???
Mar 29, 2013 at 3:25pm UTC
maeriden
(872)
It is allowed. I believe that explicitly writing that a type is a struct is only necessary in C if you don't typedef that struct.
In C++ classes and structs are the same thing except for the default access level.
Mar 29, 2013 at 3:28pm UTC
venkatacplpl
(113)
Thanks for the reply @maeriden
Topic archived. No new replies allowed.