What does push back() do to a vector in c plus plus?
The vector's push_back() member inserts one or more new elements at the end -- the back -- of the vector. If there are insufficient unused elements available, the underlying array is reallocated with a larger reserve and the existing elements moved to the new allocation, after which the new elements are appended. All iterators into the vector are rendered invalid after a reallocation.
Why you use small letter in c or c plus plus programming language?
I assume you mean using lower case letters. By convention, C and C++ standard libraries use lower-case naming conventions. This makes it easy to identify functions and types that belong to the standard library. When defining your own types, a leading capital is preferred. All capitals typically denotes a macro definition.
Who discovered of turbo c plus plus?
Turbo C++ was not discovered, it is merely one of many C++ implementations. It was originally written by Borland but is now owned by Embarcadero. The last stable release was made available in 2006, but it is no longer supported. It was succeeded by C++Builder.
Note that when learning C++, it is recommended that you use an implementation based upon the most recent standard of the language, which is currently ISO/IEC 14882::2014 (informally known as C++14) released in 2014. A new standard is expected in 2017, informally known as C++17.
Which algorithm is preferable to find a specific number from unsorted array?
If the array is unsorted then there is no algorithm that can be applied other than a sequential traversal from one end of the array to the other until the number is found or the end of the array is reached. This is an extremely poor algorithm as the worst case would be O(n) for n elements. While this may be fine for small arrays, it is highly inefficient for larger arrays.
To apply a more efficient algorithm with a worst case of O(log n), you must sort the array. You can then use a binary search algorithm by starting at the middle element. If that's your value, you're done. If not and the value you seek is less than this value, then you can eliminate all the elements in the upper half of the array, otherwise you can eliminate all the elements in the lower half of the array. Repeat the process with the remaining subarray, reducing the number of remaining elements by half each time. If you end up with a subarray with no elements then the value does not exist.
Sorted arrays that are perfectly balanced offer the best performance. For instance, an array with 63 elements is perfectly balanced because after the first iteration you are left with another perfectly balanced array of 31 elements (because you eliminated 31 elements plus the middle element). After the next iteration you will be left with 15 elements, then 7, 3, 1 and finally 0. Thus a 63-element array takes no more than 6 iterations to determine that a value does not exist, compared to 63 iterations with a sequential traversal search upon an unsorted array. 6 iterations is also the average because the 6th iteration can locate any one of 32 values, which is more than half the values.
What is the correct syntax for declaring and initializing an array that contains the numbers 0-9?
int x[]={0,1,2,3,4,5,6,7,8,9};
Is it necessary to know C or C plus plus to learn matlab?
No. Both C and C++ are low- to mid-level languages while MATLAB is a high-level language. The level determines the amount of abstraction involved, and the higher the amount of abstraction, the easier a language is to use. Knowledge of another language is never a bad thing though. The more languages you are familiar with, the more easily you can determine which language is best suited to a particular solution.
What is the order of construction and destruction in c plus plus?
The least-derived base classes are always constructed first, in the order specified by the derived class inheritance list. The most-derived class (the one you are actually instantiating) is always constructed last.
Destruction is basically the reverse of construction. However, base class destructors must be declared virtual to ensure that the most-derived class destructor is called first, regardless of which class destructor is actually invoked. That is, if you hold a pointer to a base class that has no virtual destructor, deleting that pointer will only destroy the base class, not the derived class, leaving the derived class in an invalid state (because it no longer has an underlying base class) and with no way to recover the memory it consumes.
It is important to remember that if you declare any virtual methods within a class, you must also declare the destructor virtual. A class without a virtual destructor is not intended to be derived from. If it has virtual methods, but no virtual destructor, it is not well-formed and must not be used as a base class.
When will you make inline function?
Trivial functions, such as member variable accessors that simply return a member's value, are prime candidates for inline expansion. However trivial non-member functions can also be inline expanded, as can any non-trivial function that is rarely called.
Member functions defined in the body of the class declaration are implicitly declared inline. However, whether a function is explicitly declared inline or not, the compiler is free to ignore any inline request, such as when the inline expansion of a non-trivial function would adversely compromise code size, for instance.
Note that inline expansion replaces the call to a function with a modified version of the function's body within the calling functions -- just as if you'd duplicated the code yourself, rather than creating a separate function -- which removes the overhead of making a function call.
The only way to force a function inline is to manually write the expanded code yourself. But if the code appears in several places, maintenance of the code will be compromised.
If there's ever any doubt, declare it inline and let the compiler decide. It's in a far better position to determine if it should be inline expanded or not.
What are caller and callee in c plus plus?
Caller and callee relate to function calls. The caller is the code point that made the call to a function while the function is the callee. The callee returns control to the caller via the return address that was pushed onto the stack by the caller.
void foo() {}
int main() { foo(); }
In the minimal example above, the main function is the caller while the foo function is the callee.
In short you cannot, unless you provide a suitable alternative to the standard library yourself (in other words, reinvent the wheel). At the very least you will need to include the common runtime definitions (crtdefs.h) just to create a bare-bones program that does absolutely nothing, but you'll need to implement all the standard IO functions yourself. Even third-party replacements make extensive use of the standard library, so you're completely on your own here. The standard library exists so that you can draw upon a rich set of primitive but highly optimised, tried and tested functions which act as building blocks upon which you can create your own programs.
Would you select c plus plus or java in 11 class?
Its really a matter of opinion. I prefer C++ to Java but that doesn't mean C++ is always better than Java. C++ can be rather hard to learn if you are new to it but it is a very rewarding language. On the other hand, Java is very portable and is used in just about all Android phones (I don't know enough to say whether or not all of them use java.) Anyway, if it is system development or game development you are going for, C++ is a great choice, providing low level access to the computer and providing fast speed if the code is written well. Java is a good portable language that is compiled to computer code using the Java Virtual Machine which compiles it to computer readable code and then runs which makes it portable. In the case of Java, mobile phone apps, web apps and games (most well known being Minecraft) are available to you. It all depends on what you want, hopefully with the information I have give you you can make and informed decision.
What is the difference between using a return value and a pass-by-reference parameter?
The main difference is that return values can be used in compound statements (such as assignments), whereas output parameters cannot. An output parameter is a non-const parameter that is passed by reference or as a pointer variable.
As a general rule, every function should return something through the return value, even if only an error level where zero would typically indicate success (but not always). A function that does not return anything (returns void) is not strictly a function, it is better described as a procedure. However, if a function can be guaranteed never to fail (provides trivial functionality) and has no need to return any other value to the caller, then returning void is a logical option. Just because a function should return a value doesn't mean that it must return a value.
However, the return value is limited by the fact that it only permits one value to be returned by a function. Output parameters allow a function to return several values at once and can be used in conjunction with the return value. If there is no need for the return value, it should be used to indicate the error level of the function wherever it would be appropriate. However it is not unusual for a function to accept a reference as an output parameter and to also return that same reference via the return value.
Note that although you could return multiple values via a struct or class type, this should only be considered if you have several functions that can make use of the struct or class type. However, in most cases it would be simpler to make those functions members of the struct or class itself.
Where does negative ASCII value used?
There is no such thing as a negative ASCII value. ASCII values are always in the range 0-255. In C++, a char is defined as an unsigned integer of 8-bits in length (wide chars are unsigned integers of 16-bit length). Since they are unsigned, they can never be negative.
C differs from C++ in that a C char is generally represented as a signed integer (typically 32-bits on a 32-bit system). However, when cast as a character, only the low-order byte is used, which effectively ignores the sign in the high-order byte. In other words, the absolute value is used, regardless of the sign. The same applies to wide characters.
Should you explicitly call a destructor in C programming?
Not to be pedantic, but you cannot call a destructor explicitly. Destructors are implicitly called when an object falls from scope or when you delete a pointer to an object.
Any object created dynamically (with the new keyword) must be deleted as soon as you are finished with it, and before the pointer falls from scope. In this sense, you are explicitly calling the object's destructor, however it's really being called implicitly by you deleting the pointer. It's also good practice to explicitly NULL your pointer immediately after deleting the object it pointed to.
An object reference is destroyed automatically when the reference falls from scope. If you have a pointer to that reference, do not delete the pointer, but do assign it to NULL as soon as possible to prevent any access to the deleted object. If you do delete a pointer to a reference that's still in scope, you will render the reference NULL and a NULL reference will render your program invalid.
What is the function of the Virtual Provider subcomponent of data warehousing?
Virtual data providers allow programs developed at one site to be run against data at another site. It is virtual in that there is no centrally located store of data, thus site personnel retain complete control over their own local data.
Why does a character in Java take twice as much space to store as a character in C?
Different languages use different size types for different reasons. In this case, the difference is between ASCII and Unicode. Java characters use 2-bytes to store a Unicode character so as to allow a wider variety of characters in strings, whereas C, at least by default, only uses 1 byte to store a character.
What is the latent function of friends?
The only function of a friend is to extend the private class interface outwith the class, essentially making the friend part of the class interface.
In short, mangling ensures that symbols (variables, functions, structures, classes, etc) that are by language definition local in scope to some extent in their respective namespaces (different source files, classes, libraries, etc) can't collide when taken in a global context like a linker.
What is a while statement in turbo c plus plus?
A while statement is one type of looping statement.
by which we can start a loop in our programs.
while loop is precondition checking statement,
because it first check its condition then loop will go to its body part.
EX.
while(i>0)
{
//body part
}
here when i will >0 then it will check it body part and execute it and display
result.
Is an abstract class cannot have any member variable in C plus plus?
An abstract base class may have member variables. Whether or not it actually needs member variables depends on the nature of the base class itself. If the variable is common to all derived classes, then it makes sense to place the variable in the base class. If some derived classes have no need of the variable, then it is better to derive an intermediate class with the variable, and to derive those classes that require that variable from the intermediate class, rather than directly from the abstract class.
How in C or C plus plus to static assert that a place in code be unreachable?
The only way to assert unreachable code is to place the assertion, assert(0), within the suspected unreachable code itself.
However, just because the assertion never triggers it does not follow that the code is unreachable -- only that the condition(s) required to reach that code segment have not thus far arisen. How certain can you be that the condition will never arise?
Unreachable code can sometimes be detected at compile time, depending on the compiler. Simple errors such as placing a return statement before unreachable code can normally be detected this way. However, logic errors may not always be as obvious.
For instance,
if( !condition )
// do something.
else if( condition )
// do something else.
else
assert( false ); // unreachable...
In general, if there is no logical proof to say a code segment is unreachable, it's best to leave the segment in place. An assert( false ) will alert you when the segment is hit, but even if it is never hit, you cannot be certain it will never be hit without a logical proof. If the unreachable code is trivial then it is usually not worth the effort to prove it is unreachable. If it is non-trivial, the only issue is how you test it in the event it is actually reachable. In that case you must force the conditions that would make it reachable.
Why you use constreamh in c plus plus?
There is no such header in C++. You must consult the documentation provided with the file. It is most likely related to console input/output, perhaps providing enhancements to the standard I/O stream implementation.
First question: You can define zero or more functions before main, and zero or more functions after it. It's up to you. Of course you have to have prototypes for functions which are called before their definitions.
Second question: Good programming style includes many things, for example:
- keep your functions simple, short, easy to understand and modify
- orginize the code into modules (separate source files), the size of a module should be below a few thousands line.
- don't use global variable instead of function parameters
Compression/decompression is all about raw speed and efficiency. Java is neither fast nor efficient. However, converting from C++ to Java isn't terribly difficult and Huffman's algorithm and its variations are well documented. Just don't expect to create anything that's remotely useful to you in Java.