Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

***import time
time.sleep(5) # Delays for 5 seconds. You can also use a float value.***
Here is a different case where something is run about once a minute:
***import time
while True:
print("This prints once a minute.")
time.sleep(60) # Delay for 1 minute (60 seconds).***
4 years ago
Assume, you have a class **String:**
***class String {
public:
String(int n); // allocate n bytes to the String object
String(const char *p); // initializes object with char *p
};***
Then, if you try:
***String mystring = 'x';***
The character **'x'** will be verifiably changed over to **int** and afterwards the **String(int)** constructor will be called. Yet, this isn't what the client may have planned. Thus, to forestall such conditions, we will characterize the constructor as **explicit:**
***class String {
public:
explicit String (int n); //allocate n bytes
String(const char *p); // initialize so bject with string p
};***
4 years ago
I normally apply the following process:
***#include

template
std::string NumberToString ( T Number )
{
std::ostringstream ss;
ss << Number;
return ss.str();
}***
4 years ago
Virtual destructors are required when you will be utilizing these items polymorphically. It's sufficient for the base class destructor to be **virtual;** the determined destructors will be certainly **virtual** also.

For your situation, it doesn't seem as though you will utilize the discoursed polymorphically, so maybe you needn't bother with a virtual destructor by any stretch of the imagination.
4 years ago
In the event that you simply need to pass a **std::string** to a capacity that needs **const char** you can utilize
***std::string str;
const char * c = str.c_str();***
In the event that you need to get a writable copyy, similar to **char**, you can do that with this:
***std::string str;
char * writable = new char[str.size() + 1];
std::copy(str.begin(), str.end(), writable);
writable[str.size()] = '\0'; // don't forget the terminating 0

// don't forget to free the string after finished using it
delete[] writable;***
4 years ago
**display: inline-block** joins an additional edge to your element.

I recommend this:
***#element {
display: table; /* IE8+ and all other modern browsers */
}***

You can additionally now quickly focus that fancy new **#element** just by adding **margin: 0 auto**.
4 years ago
This answer will run for a particular line and multiple lines of text, but it still needs a fixed top receptacle:
***div {
height: 100px;
line-height: 100px;
text-align: center;
border: 2px dashed #f69c55;
}
span {
display: inline-block;
vertical-align: middle;
line-height: normal;
}***
***

Hello World!
***
4 years ago
Attempt to change **a** to **block** show, and afterwards utilize any style you need. The **a** component will fill the **li** component, and you will actually want to alter its look as you need. Remember to set **li** padding to 0.
***li {
padding: 0;
overflow: hidden;
}
a {
display: block;
width: 100%;
color: ..., background: ..., border-radius: ..., etc...
}
a.active {
color: ..., background: ...
}***
4 years ago
Execution of this calculation is given beneath ?
***#include
#include

struct node {
int data;
struct node *next;
};

struct node *head = NULL;
struct node *current = NULL;

//display the list
void printList() {

struct node *ptr = head;

printf("\n[head] =>");
//start from the beginning
while(ptr != NULL) {
printf(" %d =>",ptr->data);
ptr = ptr->next;
}

printf(" [null]\n");
}

//insert link at the first location
void insert(int data) {
//create a link
struct node *link = (struct node*) malloc(sizeof(struct node));

//link->key = key;
link->data = data;

//point it to old first node
link->next = head;

//point first to new first node
head = link;
}

int main() {
insert(10);
insert(20);
insert(30);
insert(1);
insert(40);
insert(56);

printList();
return 0;
}***

Output of the program should be ?

***[head] => 56 => 40 => 1 => 30 => 20 => 10 => [null]***
4 years ago
One use instance of **git fetch** is that the accompanying will reveal to you any progressions in the far off branch since your last draw... so you can check prior to doing a genuine draw, which could change documents in your present branch and working duplicate.
***git fetch
git diff ...origin***
4 years ago
In one of my old project that didn't utilize jQuery, I assembled the accompanying capacities for adding, eliminating and checking if the component has class:
***function hasClass(ele, cls) {
return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
}
function addClass(ele, cls) {
if (!hasClass(ele, cls)) ele.className += " " + cls;
}
function removeClass(ele, cls) {
if (hasClass(ele, cls)) {
var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
ele.className = ele.className.replace(reg, ' ');
}
}***
Along these lines, for instance, on the off chance that I need onclick to add some class to the catch I can utilize this:
***
...
***
4 years ago
I would sincerely recommend not one or the other. I would utilize an adapted **** for that conduct
***button.link {
display: inline-block;
position: relative;
background-color: transparent;
cursor: pointer;
border: 0;
padding: 0;
color: #00f;
text-decoration: underline;
font: inherit;
}

A button that looks like a .

***

On the off chance that you MUST utilize A component, use **javascript:void(0)**; for reasons previously referenced.

Will consistently block on the off chance that your onclick occasion fizzles.

Won't have wayward burden calls occur, or trigger different occasions dependent on a hash change

The hash tag can cause sudden conduct if the snap fails to work out (onclick tosses), keep away from it except if it's a suitable fall-through conduct, and you need to change the route history.
4 years ago