answersLogoWhite

0

📱

C++ Programming

Questions related to the C++ Computer Programming Language. This ranges all the way from K&R C to the most recent ANSI incarnations of C++, including advanced topics such as Object Oriented Design and Programming, Standard Template Library, and Exceptions. C++ has become one of the most popular languages today, and has been used to write all sort of things for nearly all of the modern operating systems and applications." It it a good compromise between speed, advanced power, and complexity.

2,546 Questions

Is Java the best programming language to develop an operating system - I want to know if Java is capable of producing a good operating system except other languages like C plus plus Python Ruby VB etc?

No. Apart from anything else, Java must run in a virtual machine. The only way to write an OS that runs in a VM is if the VM exists in firmware. Even so, the level of abstraction in the VM would make it unworkable. Java does not have any direct access to the hardware, which is a prerequisite for any OS. Even if it were actually possible to write an OS in Java, it would be slower than molasses for even the most basic operations.

C++ is the only real option here, combined with assembler for low-level operations. Of course you must have a complete understanding of all the hardware your OS could run on. The more variable the hardware, the more complex the OS needs to be. Gone are the days when a single programmer threw an OS together in their spare time. These days, we'll take an existing open-source OS and modify it to suit. Even so, it's still a major undertaking.

What are all the objects oriented programmes?

For a fairly exhaustive list, see the related link to this question. Popular languages are C++, Java, Objective-C, Visual Basic, and Ruby.

Can anyone provide me a executable C or C plus plus language source code for netstat in Windows XP environment?

Netstat for Windows is provided by Microsoft itself, so you're unlikely to find any source code for it. However you may find Linux versions of Netstat source code available. The functionality may differ to some extent, but how useful they are will depend on why you need the source code in the first place.

What is anonymous objects in c plus plus?

There is no such thing as an anonymous object in C++ (no such term is defined by the standard). You can have anonymous classes, anonymous unions or unnamed objects, but never anonymous objects.

Consider the following:

int* p = new int();

This creates two variables: a pointer variable on the stack (named p) and an integer variable on the heap (unnamed). Although the int on the heap has no name of its own, it is identified by dereferencing the address stored in p (*p), so it is not strictly anonymous.

struct foo {

//...

foo operator++(int);

};

In the above example, the int parameter is unnamed, but since it is never referenced (because it is not used) it is not strictly anonymous.

You might consider the following an anonymous object:

class foo{};

void bar(foo& f){}

int main() {

bar( foo() );

}

The instance of foo in main is merely unnamed. When passed to bar, it is identified by the f reference, so it cannot be regarded as an anonymous object. Upon returning from bar, the unnamed instance falls from scope. At best this can be described as a temporary unnamed object, but not an anonymous object.

What are the components of loop?

a loop consist of

data initialization;test condition;updation;

example a for loop

for(int a=1;a<5;a++)

the loop will be executed 5 times

four positives result and the last test condition will be failed and the loop will be exited

there are many loops some of them are

while loop,do...while loop,for loop,maybe more......

do while is an exit check loop and while and for are entry check loop.

Can you give me an example of source code using gotoxy and Microsoft visual basic c plus plus 2006?

can you help me create a program that will have the following output:

[1] Volume of Ellipsoid

[2] Volume of Prolate Spheroid

[3] Surface Area of Prolate Spheroid

[4] Volume of Oblate Spheroid

[5] Surface Area of Oblate Spheroid

[6] Surface Area of Spherical Triangle

Enter Your Choice:

You have chosen:

Enter Side a:

Enter Side b:

Enter Side c:

Volume =

Do you want to try again? [Y/N]

...

it must use gotoxy and clear screen after choosing Y or N ( in do you want to try again)

it must be used in Microsoft visual basic c++ 2006,,

here are the following formulas;;

Volume of Ellipsoid = (4/3)*3.14*a*b*c

( input a,b,c)

Volume of Prolate Spheroid = (4/3)*3.14*a*(pow(b,2))

(input a,b)

Surface Area of Prolate Spheroid = 2*3.14*b*L

(input b,L)

Volume of Oblate Spheroid = (4/3)*3.14*(pow(a,2))*b

Surface Area of Oblate Spheroid = 2*3.14*a*y

where:

y = a+(number/denom)

number = pow(b,2)

denom = 2(sqrt(pow(a,2)-pow(b,2))

(input a,b)

Surface of Spherical Triangle = ( A+B+C-3.14)*pow(r,2)

(input A,B,C,r)

What is obfuscation of source code?

Obfuscation of source code is the practice of formatting the code to be difficult to understand. It also makes it difficult to support. Since source code development and support is a team effort, I would fire anyone that deliberately obfuscates their code. (After appropriate warning, of course.)

As an example of this team effort attitude, I was part of a team that wrote code for the IBM MainFrame. Policy was that code maintainers should use the style of the original author, so as to minimize future complication in support. Policy, also, was that new code be written in COBOL II, even though my manager knew I was a C/C++ Master, and we did have a C compiler, because if some of my code needed to be supported when I was not around, the number of people that understood COBOL II in a MainFrame environment was greater (at that time) then the number of people that knew C/C++.

What is abstract data type in c plus plus?

Abstract data types are the opposite of a concrete data types. An abstract data type is one that does not contain all of the function code necessary to create an instance of the object. This design allows subclasses to implement the abstract functions while inheriting the non-abstract functions of the class. A pointer to an abstract instance can call all the abstract functions of that object, which will defer their execution to the actual concrete data type's implementation of that function. As a simple example, an abstract class ChessPiece might have a function called move(). A Pawn subclass would behave differently than a Queen would, but both could be called by outside code without knowing (or caring) about what type of ChessPiece is moving.

Correction

Abstract classes can provide a full and complete (if generic) implementation for all of their pure-virtual functions. It is not the lack of a complete implementation that renders them abstract, but the fact the methods were declared pure-virtual and therefore cannot be inherited. However, derived classes can still call those implementations from within their own implementations.

Furthermore, derived classes that do not provide implementations for all the pure-virtual methods become abstract base classes themselves. But the pure-virtual methods that they do implement can then be inherited through multi-level inheritance.

Non-inheritance of pure-virtual methods only applies to the class that initially declared the method as pure-virtual. Provided an implementation is declared protected or public within a derived class, that implementation can then be inherited by a concrete class, or it can be overridden if required.

Why c plus plus compiler cannot produce byte code?

Byte code would be detrimental to performance because byte code must run in a virtual machine. Java compiles to byte code suitable for the Java Virtual Machine (JVM), but C++ compiles to native machine code. For that reason alone, C++ programs perform many times better than equivalent Java programs. However, the need for a virtual machine also means Java is highly-abstract, with no direct access to specific architecture features. C++ has no such limitations and can therefore produce highly-efficient code specific to any platform. Java simply cannot compete for performance, but Java programs need only be compiled once to run on any platform that supports the JVM, whereas C++ must be compiled separately for each platform, and preprocessor directive code must be written to suit each supported platform. This naturally requires a lot more work on the part of the programmer, but the performance speaks for itself.

What is the short cut in word that uses ctrl plus shift plus plussign?

In Microsoft Word, CTRL+SHIFT+PLUS is used to apply superscript formatting with automatic spacing to the selected text.

Why quick sort taks more time in small arrays?

The short answer is that quick-sort is ideally suited to sorting large sets of data. With small sets of data, the combination of selecting an optimal pivot, partitioning the set and the need to recursively call itself adds an overhead that even the most inefficient bubble-sort can easily overcome via iteration alone. Using triple partitioning to ensure stability simply adds to the overhead.

I haven't tested the effects on arrays, but using in place sorting of doubly-linked lists with inline, triple-partitioning and non-recursive tail calls, I've found the cut off point is around 20 items. Anything less and an optimised bubble-sort performs better on average. However the actual difference is negligible -- only a few microseconds. On a modern computer, no-one is going to notice the difference.

For larger datasets, the quick sort is hard to beat unless the dataset is already sorted. I cater for that by performing a single-pass optimised bubble-sort. If a change is detected and the unsorted subset has 20 or more items, a quick-sort controls the remainder of the sorting process.

Can we used c plus plus language for 3d game developing?

Yes, and it's a good choice.

You can use almost all languages for creating 3D games, but you probably want ones that have DirectX/OpenGL bindings(or support them natively), like:

C

C++

Pascal

Python

LUA

C#

Java

And many others.

If you're not very experienced I'd recommend an easier language, like Python.

What will be the fate of IS professional if he doesn't understand programming?

It depends on what the IS professional is called upon to do. You do not have to understand programming to be able to use and support computers, but it is very helpful. On the other hand, if you have to write programs and you do not understand programming, you will fail. This, unfortunately, also includes administrative things such as writing GPO scripts, so it would be a good idea to learn programming.

What are some easy ways to improve the quality of your C plus plus code?

One of the easiest ways to improve your code quality is to keep your comments to a minimum. Use a verbose comment to introduce your code, summarising its purpose and features, but try and keep the code itself as comment-free as possible. This way, the reader can follow the flow of the code without constant interruption from the programmer. Comments within your code should only be used to clarify anything that is unclear, without simply restating what the code does. That is, what the code does is explained by the code itself, but it isn't always clear why the code does what it does.

If a verbose comment is required in order to explain the purpose of a particular line of code, try rewriting that line in such a way that it becomes clearer from the code itself. Make good use of whitespace to make it clearer what's going on. Good code should also be largely self-documenting, so if the logic is obfuscated by a complex series of statements, place those statements in separate functions with meaningful names so that the code documents itself more easily. Using functions in this way costs nothing since simple functions will be inline expanded by the compiler.

Avoid code duplication at all costs. Rewriting the same code over and over, or copy/pasting code, leads to increased maintenance and error-prone code whenever that code needs to be altered. Even if the code has slight differences there are usually ways to generalise the code either as a single function call, or a series of function calls to cater for differences. This greatly reduces maintenance costs because any changes to a particular call need only be made in one function, rather than every location that uses the code. With C++ this concept extends to objects as well. Make good use of inheritance and abstraction to provide more specialised versions of your generic code.

These are probably the simplest methods to improve the quality of your code. Ultimately, the quality of your code is determined by your consistency and your style. That is, stick to common conventions as much as possible. Ensure all your objects obey the one-resource-per-object rule. Objects that mutate multiple resources are a design flaw which will only lead to problems further down the line.

Why an array is called derived data type?

it contains the similar type of object which derive from the predefined data type

like int,float,char e.t.c

so it is called derived data type.........................

Application of array in data structure?

That rather depends on the underlying type. For any given type T, an array of type T is user-defined if T is user-defined, otherwise it is built-in. For example:

#include<string> // required to use std::string

std::string s[42]; // user-defined array

int i[42]; // built-in array

Here, s is a user-defined array because std::string is a user-defined type, whereas i is a built-in array because int is a built-in type.

What is the syntax and purpose of the switch statement in c plus plus?

The purpose of a switch statement is to execute one of several sections of code, depending on the value of an integral expression.

The syntax of a switch statement can be stated as follows:

switch(expression)

{

case(constant_expression_1): statement

case(constant_expression_2): statement

//..

case(constant_expression_n): statement

[default: statement]

}

The ellipses around the constant expressions are optional and may be omitted.

The switch statement body consists of one or more case labels and an optional default label (the case labels are also optional, but a switch statement would be meaningless without them). The default statement, if present, need not be the final label in a switch statement. Case and default labels may not appear outside of a switch statement, as they are not treated the same as goto labels.

The constant_expression in each case label is converted to the type of the switch expression and is compared with the switch expression for equality. Control is immediately passed to the labelled statement whose constant_expression matches the value of the switch expression.

Once a label gains control, execution proceeds from that point on and is not impeded by any subsequent case or default labels. However, a break statement may be used to interrupt execution at any time, which will transfer control to the statement immediately following the switch statement body. You may also use a return statement to return control to the calling function, or a goto statement. However, note that while a goto label is not the same as a case label, you may use goto labels inside a switch statement if required.

Here's an example demonstrating how code flows through a switch statement:

int x;

switch(x=rand()%10) // x is a random number in the range 0 to 9.

{

case(0): x=42; break;

case(1):

case(2): x=33; break;

case(3): x=100;

default: x=0;

}

If x were 0, then execution passes to case(0) where the value 42 is assigned to x and the switch exits.

If x were 1 or 2, then 33 is assigned to x and the switch exits.

If x were 3, 100 is assigned to x.

In all other cases, 0 is assigned to x.

You will note that when the switch statement ends, x can only ever be 42, 33 or 0. Why not 100? Look again and you will see that case(3) has no break statement (just as case(1) has no break statement). So although 100 is assigned to x in case(3), the default case immediately assigns 0 to x.

This is not a particularly useful switch statement, but it serves to demonstrate how code flows through a switch statement, and how forgetting to put a break statement at the end of a case can cause unexpected errors to creep into your code.

While you could emulate the same results using a series of if, else if and else statements, the benefit of a switch statement is that it will generally simplify the complexity of your code, because there is only one expression to evaluate, rather than a series of boolean expressions. Your compiler will generate machine code just as if you'd used a series of if statements, but the switch statement gives a greater sense of structure to the statement, and gives a greater degree of control over which section(s) of code will execute for any given evaluation. And just as ifs can be nested within other ifs, switch statements can be nested within other switch statements.

Note that all code in a switch statement must be reachable (that is, not bypassed by all execution paths). For instance the following contains both unreachable and undefined code:

switch(x)

{

x=42; //unreachable

case(100):

int y=42;

break;

default:

x=y; // y is undefined

}

The line x=42 cannot be reached because execution must either pass to either the case(100) or the default label. Similarly, the x=y line is invalid because y is defined within the case(100) label, which is not reachable from within the default label due to the break statement.

Where can you download MFC include files?

In short, you cannot legally download the Microsoft Foundation Classes (MFC) library for free. The only way to obtain it is to purchase a Microsoft Visual C++ product as it is not provided with the free Microsoft Visual C++ Express.

Note that although Borland licenced the MFC library at one time, for use in Borland Turbo C++, they never fully integrated with MFC and eventually dropped it altogether in favour of their proprietary Visual Component Library (VCL) which replaced the Object Windows Library (OWL) that Borland had used prior to licencing MFC. No other C++ product licenced the MFC library.

Note also that the MFC library is simply a wrapper for portions of the Windows API and was originally called Application Framework Extensions, hence the use of the abbreviation AFX rather than MFC throughout the library.

Define objects and show how they act as user defined data type in c plus plus with the help of a programme?

An object is an instance of a class. A class is a data type that combines data and the specific methods that operate upon that data into a self-contained entity.

To prove that objects are user-defined types, consider the following:

class foo

{

};

int main()

{

foo a;

foo b;

foo c = a + b; // ERROR!

}

The reason there is an error is because the plus operator (+) only works with primitive data types (integral, arithmetic and built-in data types). foo is neither an integral, arithmetic nor built-in data type, thus the plus operator is not supported.

However, if you provide a user-defined plus operator overload (foo::operator+) that accepts a constant reference to a foo object, the code will compile. It's up to you, the class designer, to provide the appropriate implementation.

Explain in detail datatype supported in 'C plus plus ' language?

char: A one-byte integer with implementation-defined signedness.

signed char: A signed one-byte integer.

unsigned char: An unsigned one-byte integer.

wchar_t: A wide character of implementation-defined size and signedness.

short: A signed integer with at least 16 bits.

unsigned short: An unsigned integer with at least 16 bits.

int: A signed integer with at least 16 bits.

unsigned int: An unsigned integer with at least 16 bits.

long: A signed integer with at least 32 bits.

unsigned long: An unsigned integer with at least 32 bits.

long long: A signed integer with at least 64 bits.

unsigned long long: An unsigned integer with at least 64 bits.

float: A floating-point number with 32 bits of precision.

double: A floating-point number with 64 bits of precision.

  • long double: A floating-point number with 80-96 bits of precision.

Is GUI better in Java or C plus plus?

Neither Java nor C++ have a GUI as such -- the GUI is not part of the language specification. But comparing the GUIs for an IDE intended for Java with that of an IDE intended for C++ is hardly going to tell you which is better, since they are intended for completely different purposes. You might as well compare the GUI provided with Adobe PaintShop Pro against the GUI for Microsoft Word for all the good it does.