answersLogoWhite

0


Best Answer

Classes cannot return values, only functions can return values. But you cannot return a function from a function, you can only return a function pointer -- a pointer variable holding the address of the function you wish to return. All possible return values must be of the same type, therefore all function signatures and return types must be exactly the same -- only the name of the functions can differ.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to return a function using class in C Plus Plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is main advantage of using constructors in java?

Constructors have the same name as the class itself and they do not specify a return type, not even void because they return the instance of the class itself. Because constructors have the same name as the class then they allow method overloading and also save memory and execution time of program. Program release memory of constructors function after using this function and it reduce program complexity.


How to write C plus plus Program to take 2 distant values as argument and return the larger value on the screen?

Use the following template function: template<class T> T& max(T& x, T& y){return(y<x?x:y;}


Write a java program of addition of two variables?

public class AddNumbers{ public int add(int a, int b){ return a + b; } }


Write a program to find the grade obtained by the students of a class using structure?

Write a program to find the grade obtained by the students of a class


What are the advantages of having program in a class in C plus plus?

You don't write programs in a class in C++, you write programs that use classes. Every C++ has at least one function, main, the entry point of the application. You define the classes and functions that are used by your main function. Classes allow you to classify the objects used by your program, allowing data to be manipulated in a highly controlled manner, ensuring consistency and robustness throughout your program.


How do you write a binomial distribution table in C program?

Class&genus


Write c plus plus program for new and delete operator using class?

#include<iostream> class foo{ int m_data; }; int main() { foo* p=new foo; delete( foo), foo=NULL; return(0); }


When you make a c program in c language then how many types class are required?

It depends on what you mean by 'types class'. Here is the shortest C program, without any 'types class': int main (void) { return 0; }


Program to find biggest number among two numbers using template function?

template<class T> T& max(const T& x, const T&y){return(x>y?x:y); }


True or False A C plus plus class constructor cannot return a function value?

True - A C++ constructor cannot return a value.


Write a program to display the name of days when a user enters a number?

write a program to display your name age class schoolname e-mail 2hobby based on choice


Can you use the same function name for a member functoin of a class and an outside function in the same program file?

Yes you can use the same function name for a member function and an external function. They are primarily distinguished by the number and type of arguments they accept (the function signature). If they match exactly, then the scope resolution operator (::) is used to differentiate them by namespace. The class namespace is the class name itself. The external function uses global scope unless scoped to another namespace. When the scope is not explicitly stated, then the scope is implied by the call site. Note that whenever there is any ambiguity about which function is implied, the compiler will emit an error indicating where the ambiguity lies, and the program will ultimately fail to compile.