0

I have used the following code to play a sound:

<object>
<param name="autostart" value="true">
<param name="src" value="bgmusic.mp3">
<param name="autoplay" value="true">
<param name="controller" value="true">

<embed id="hidden-embed" src="bgmusic.mp3" controller="true" volume="1" autoplay="true" autostart="True" type="audio/mpeg" hidden="true" loop="true" />
</object>

The mp3 is being played in a notmal html page. However when putting the same tags in a jsp page its not being played. Any suggestions would be of great help.


Vector with template gives error in Valgrind when printing the context

I am very confused why my code gives error when running the valgrind memory check:

valgrind --tool=memcheck --leak-check=yes ./output

The code works perfectly when compile and run. But when running the valgrind tool it gives this message in the end.

ERROR SUMMARY: 170 errors from 9 contexts (suppressed: 2 from 2)

It would be wonderful if someone could help me out.
Thank you /Pete

#include <iostream>
#include <cstdlib>
#include <list>
#include <stdexcept>
#include <algorithm>

using namespace std;

template <typename T>

class Vector{
public:
    T* p;
    size_t size;
public:
Vector<T>(){
    cout << "The default constructor" << endl;
    this-> size = 10;    // initial size
    this->    p = new T[size];

}
~Vector<T>(){
    cout << "The destructor" << endl;
    delete [] p;
}

void print_values(){
        for (unsigned i = 0; i < this->size; ++i){
            std::cout << *(this->p+i) << " ";}
        std::cout << endl;
}   

};

int main(){
Vector <double> dvect;
//dvect.print_values();   // why gives error?
}
4

0 回答 0