What are the benefits of byte as a datatype?
A byte is the smallest unit of addressable storage. Although a bit is smaller than a byte, a single bit cannot be addressed directly; we always deal with groups of bits and a byte is the smallest group of bits that can be physically addressed. However, once we have addressed a byte, we can then examine the individual bits within it using the bitwise logic operators (AND, OR, NOT and XOR).
On most systems a byte is exactly 8 bits in length. The reason for this is simply that we can represent any 8-bit value using a convenient two-digit hexadecimal notation, where each hex digit represents exactly 4-bits (often called a nybble because it is half-a-byte). Thus an 8-bit byte can be represented by any hexadecimal value in the range 0x00 to 0xff (or 0 to 255 decimal).
(Some systems use odd-size bytes, such as a 9-bit byte. For this we typically use 3-digit octal notation because an octal digit represents exactly 3 bits. Such systems are rare, but we sometimes come across other odd-sized bytes, especially in older data transfer systems such as dot-matrix printers which utilised a 7-bit byte. However, in modern architecture, we can safely say that a byte is always at least 8 bits long.)
Not all programming languages utilise a byte data type as such. C, for instance, doesn't have a built in byte data type but it does have a char data type which is always 1 byte in length. There's no real reason why there isn't a byte data type in C, but when all data types are measured in terms of bytes it was probably deemed unnecessary to say that a byte is 1 byte in length. Although a char is typically used to encode a single character from a character set (and has built in overloads specific to that purpose), the encoding is no less numeric than a byte would be, so there was no real need for a separate byte data type.
Although a single byte can represent any decimal value in the range 0 to 255, it is more correct to say that a single byte can represent any one of 256 unique abstractions. Whether it is a single character from a character set, an unsigned value in the range 0 to 256, or a signed value in the range -128 to +127, these are merely abstractions. How abstractions are interpreted is entirely down to the programmer and/or the programming language.
What is the structure of nylon 66?
Nylon is a generic name for a synthetic linear polymer with repeating amide groups (-NH-CO-) which is used in the manufacture of textile fibres. Carothers produced Nylon 66 by condensation reaction of adipic acid (a dicarboxylic acid with 6 carbon atoms) and hexamethylenediamine (a diamine with 6 carbon atoms) give the [-NH-(CH2)6-NH-CO(CH2)4-CO-] repeating unit. Nylon revolutionised the textile industry and was the forerunner for many of today's modern, synthetic fabrics.
You cannot throw an exception from a destructor?
Sure you can, but it's never a good idea. You must never allow an exception to escape from a destructor. To do so would terminate the destructor prematurely, unwinding the call stack in search of an exception handler. This means that any remaining resources consumed by the instance, including its base classes, would be left in an invalid state with no possible way to recover those resources besides terminating the program. Any object that has the potential to throw an exception during its own destruction should always be treated with suspicion; it is a major design flaw.
How should you design a scientific calculator using C plus plus?
The easiest way to implement a calculator is an RPN calculator (enter the numbers first, perform the operation last). You need a last-in-first-out stack (there's a "stack" class in C++, but you can also implement your own using an array or a linked list), and a set of functions that pop the last elements from the stack and push the result (e.g. Add() pops the last 2 values and pushes their addition).
You'll need the math.h library for scientific operations.
Why wont your c plus plus program stay open?
If you are talking about the program executing, but the output screen being displayed for a flash and then disappearing, I suggest adding getch() or getchar() function at the end of your main function. This will make sure that the output screen waits for you to press a character before the program terminates.
How do you pass an array to a copy constructor in c plus plus?
You cannot pass an array to a copy constructor. A copy constructor only accepts a constant reference to the object being copied, which must be of the same class as the object being constructed. An array is not an object of any class, and therefore cannot be used in any copy constructor.
Although you cannot pass an array to a copy constructor, you can pass an array to a non-trivial constructor. It is not recommended, however, as there's no way to bounds-check the array being passed, which could result in an invalid object being created -- which is never a good thing. Even if you pass the array and its dimension(s) to the constructor, how can you guarantee those dimensions are valid for the array being passed? And what will you do if they are invalid? After all, you cannot veto the construction of an object once you've called its class constructor.
Not knowing why you want to pass an array to a copy constructor, or how you intend to initialise the members via an array, makes it somewhat difficult to determine the best solution for you. However, I would consider using mutators instead of constructors. There's still the problem with bounds-checking but at least you won't have to deal with it during the object's construction.
It has several meanings, none of which have anything to do with computer programming. In mathematics, a Quadrature is a numerical integration.
Why recursive solution is better for tree traversal?
Because a tree is a recursive data-structure. It's easier to write (and easier to understand) a recursive program for handling it.
What Cygwin packages do I need to download for compiling C plus plus files?
g++, gdb and make. A simple search for "Cygwin c++" will tell you all you need to know.
How can you get a specific string from large string using c plus plus strings?
std::string::substr();
What is the use of Constructor with Dynamic allocation?
Constructors are necessary to initialize classes. It allows to avoid to a lot of problems with unauthorized access of memory.
Dynamic allocation makes possible allocation of memory during execution of program. If you do not use dynamic allocation, all required memory will be allocated during initialization phase (constructors are usually responsible for that). But you can't use more memory. Dynamic allocation was designed to overcome such problems.
What is named user plus perpetual?
Named User Plus is the licencing metric for a single unique user. Perpetual relates to the term of the licence. Being perpetual means that the licence lasts for life.
What is the advantage of breaking applications code into several small functions?
BY breaking the code into various member functions, it becomes easy to make any desired changes in the program. It becomes easy to comprehend the code.
The most important use of pointers comes when we pass value by reference to any function. You do not need to create a second memory location as in pass by value. You can mofify the original variable by using its address.
A bit copy of an object is an exact, bit-by-bit, copy of that object. The default copy constructor generated by the compiler makes a bit copy.
This is potentially a problem if the object contains pointers to other objects...
A bit copy of a pointer copies the pointer, but not its data. This means that you have two pointers pointing at the same object in memory. If you delete one of them, the other becomes invalid, and this can (usually does) cause corruption.
If an object contains a pointer, the object's copy constructor should provide for proper allocation and copying of any pointed to objects within that object.
Does break statement terminate only the inner loop in c?
Yes. Break terminates only the innermost control structure, loop, switch, etc. If you want to break out of nested control structures, you can set a variable to induce a second break, or you can throw an exception.
The only things that may be different for all objects of a class are their member variables. They represent the object's data. The only things that remain the same are the static members -- they are akin to global variables, but are local to all objects of the class type.
A C plus plus program is a collection of one or more what?
A C plus plus program is a collection of one or more translation units. Every C++ program requires at least one translation unit that defines the global main function, the entry point of the application. Typically, the global main function is used to parse any command line switches and delegate primary operations to one or more lower-level functions.
A translation unit is the smallest unit that can be processed by the C++ compiler. During compilation, only those units that have changed since the previous compilation need be recompiled. A unit is essentially a source file (typically a *.cpp file) and source files are typically divided up by the classes and/or functions they define, thus allowing programmers to create self-contained code modules that can used by other applications. Typically, a source file has a corresponding header file (typically a *.h file) which must be included by the source file (using the #include precompiler directive). The header typically describes the translation unit's interface and may be included in other translation units that require access to that interface.
A class is a user-defined type, in much the same way that an int or float is a built-in type. The class definition describes the type's representation and interface; the operations that are valid for the type. Class interfaces are typically defined in header files and implemented in source files. However, class templates need to be completely defined in the header as these are used by the compiler to generate types at the point of instantiation and the compiler needs to "see" the complete template definition in advance of any usage of that template.
Why doesn't the main function need a prototype statement?
Because we usually don't call it from the program, but if we do, you should have a prototype:
int main (int argc, char **argv);
int foobar (const char *progname)
{
char *param[2];
...
param[0]= progname;
param[1]= "help";
main (2, param);
...
}
int main (int argc, char **argv)
{
...
foobar (argv[0]);
...
}
How do you search a character in a inputted string?
#include <iostream>
#include <string>
using std::string;
using std::cin;
using std::cout;
using std::endl;
using std::getline;
int main()
{
string myString = "";
cout << "Enter a string: ";
getline(cin, myString);
char mySymbol = 'a';
cout << "Enter a symbol to search for: ";
mySymbol = getchar();
bool symbolFound = false;
for (int index = 0; index < myString.length(); index++)
{
if (mySymbol false)
{
cout << "The symbol " << mySymbol << " was not found!";
}
cin.get();
cin.get();
return 0;
}
Why a static data member can be accessed through main?
Static data members are local to the class, not to any instance of the class. That is, you do not need to instantiate an object of the class to access them. They are shared variables, not unlike global variables, the only difference being that that can also be hidden behind static member accessors and/or mutators (get and set methods) of the class. However, a public static data member is a global variable in all but name.
Since they do not belong to any instance of the class, they must be initialised outside of the class, and outside of any other code blocks. In other words, they are initialised at compile time and are therefore available at runtime, and can therefore be accessed from the main function if a public interface is implemented or the member is declared public. If it is declared private, the variable is treated as a shared variable that is only accessible to all static members of the class, to all instances of the class and to all friends of the class. If declared protected, it is also accessible to derived classes.