.
  Vyom World.com . Let's Touch the Sky Together!  
.

Home
VyomWorld.com Home
Interview Questions
VyomLinks.com Home
JobsAssist.com Home
Vyom Network
Contact Us
Jobs & Careers
Resume Submitter
Placement Papers
IT Companies Directory
Computer Jobs
Interview Questions
Online Exams
Vyom Career eMag.
Fun
Send FREE SMS!
SMS Jokes
Source Codes Library
Source Codes Home
ASP Source Codes
C Source Codes
C++ Source Codes
COBOL Source Codes
Java Source Codes
Pascal Source Codes
Submit Source Codes
GATE
GATE an Overview
GATE Preparation
Study Materal
GRE
GRE an Overview
GRE Questions
GRE Preparation
GRE Universities
TOEFL Preparation
TOEFL Resources
GMAT Preparation
GMAT Resources
MBA Preparation
MBA Resources
Networking Concepts
Networking Concepts
Testing Preparation
Testing Resources
Webmasters
Free Traffic Builder
Webmaster Articles
Web Hosting
Tutorials
Hardware Tutorial
1500 Free eBooks New!


Home » Placement Papers » Texas Placement Papers » Texas Previous Year Placement Paper

 

Texas Placement Paper -: C++ Questions And Answers


Advertisements
Advertisements




Texas Previous Years Solved Sample Placement Papers

1. Can we declare a static function as virtual?

Answer: No. Static functions are not related to any object, while virtual functions depend on the specific object to determine which function to call. Hence, static functions cannot be declared as virtual.

2. Can a user-defined object be declared as a static data member of another class?

Answer: Yes. Example:

#include<iostream>
class test {
    int i;
public:
    test(int ii = 0) { i = ii; }
};
class sample {
    static test s;
};
test sample::s(26);  // Initializing the object `s`

3. What is forward referencing, and when should it be used?

Answer: Forward referencing declares a class or function before its definition to avoid compilation errors. Example:

class sample;  // Forward declaration
class test {
public:
    friend void fun(sample, test);
};
class sample {
public:
    friend void fun(sample, test);
};
void fun(sample s, test t) {
    // Implementation
}

4. What is the istream_withassign class?

Answer: The istream_withassign class is derived from istream, adding overloaded assignment operators to make objects copyable. The base classes (istream, ostream, and iostream) have private copy constructors and assignment operators, making them uncopyable.

5. How do I write a zero-argument manipulator that works like hex?

Answer: Example:

#include<iostream>
using namespace std;

ostream& myhex(ostream &o) {
    o.setf(ios::hex);
    return o;
}

void main() {
    cout << endl << myhex << 2000;
}

6. Why does the following code work without initializing p?

const char *p;
p = "A const pointer";
cout << p;

Answer: The pointer p is not constant, but the value it points to is. Hence, it can be assigned a string literal.

7. How do I refer to a class or function within a namespace?

Answer:

  • Using Scope Resolution Operator:
    namespace name1 { class sample1 {}; }
    name1::sample1 s1;
    
  • Using the using keyword:
    using namespace name1;
    sample1 s1;
    

8. Can default values be provided while overloading binary operators?

Answer: No. Providing default arguments leads to ambiguity in operator usage.

sample operator+(sample a, sample b = sample(2, 3.5f)) {}

9. How do I convert one user-defined type to another?

Answer: Use a conversion function. Example:

class circle {
    int radius;
public:
    circle(int r = 0) : radius(r) {}
};
class rectangle {
    int length, breadth;
public:
    rectangle(int l, int b) : length(l), breadth(b) {}
    operator circle() {
        return circle(length);
    }
};
void main() {
    rectangle r(20, 10);
    circle c = r;  // Conversion occurs here
}

10. How to ensure only one instance of a class is created?

Answer: Implement a singleton design pattern. Example:

#include<iostream>
class sample {
    static sample *ptr;
    sample() {}
public:
    static sample* create() {
        if (ptr == NULL) ptr = new sample;
        return ptr;
    }
};
sample* sample::ptr = NULL;

void main() {
    sample* a = sample::create();
    sample* b = sample::create();
    // Both `a` and `b` point to the same instance
}

11. How to implement get and put properties in a class?

Answer: Use __declspec(property). Example:

#include<iostream>
class sample {
    int data;
public:
    __declspec(property(put = set, get = get)) int x;
    void set(int i) { data = (i < 0) ? 0 : i; }
    int get() { return data; }
};
void main() {
    sample a;
    a.x = -99;  // Calls `set` method
    cout << a.x;  // Calls `get` method
}




 


.

Recently Updated: New Placement Papers added.
Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Programming & Source Codes | GRE Preparation | Jobs, Discussions | Software Listing | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | International Business Information | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | FAQs | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Excellent Mobiles | Software Testing | Interview Questions | Freshers Jobs | Server Insiders | File Extension Directory

Copyright ©2003-2024 Vyom Technosoft Pvt. Ltd., All Rights Reserved. Read our Privacy Policy